BashScripts.org
http://bashscripts.org/forum/

create mutliple files based on list of different names
http://bashscripts.org/forum/viewtopic.php?f=8&t=1713
Page 1 of 1

Author:  trogdor [ Thu Jun 06, 2013 9:40 am ]
Post subject:  create mutliple files based on list of different names

Before I get started, I should preface this by saying I suck at this. I'm trying to learn, but am pressed for time. Any help is greatly appreciated

From a list of names, I need to create ~200 files that look similar to this:


Code:
[Groupname;mb;typeservermb1]
     address typeservermb1.server.com #note the whitespace


the name of the file would be typeservermb1.conf

The items that would be variables are:
mb
type
server
mb
1
typeservermb1

The list of names looks like:

typeservermb1
typeserverab2
typeserverpt3
etc.

So, everything needs to be based off of the name given. I would like that list of ~200 names to come from a separate file.

Here's what I have so far (way off track, I am sure)

Code:
#!/bin/bash
#create files based on name
cat file.txt | while read LINE
do
    echo  >> /home/user/dir/${1}.conf   
done
#for every file created, write the following
#note - this is where I am completely lost
  $mb= #based on name of file? Or from list? Also, can be equal to mb, ab, or pt
  $type= #can be equal to bry o trk
  $server= #can be grx3 or lkh3iu
  $1= #a number - i think 100 is the highest it goes

[Groupname;$mb;$type$server$mb$1]
     address $type$server$mb$1.server.com

Page 1 of 1 All times are UTC - 6 hours
© 2000, 2002, 2005, 2007 phpBB Group • http://www.phpbb.com