Register
It is currently Wed Nov 26, 2014 2:51 am

create mutliple files based on list of different names


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Thu Jun 06, 2013 9:40 am   

Joined: Thu Jun 06, 2013 8:59 am
Posts: 1
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


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP