Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Append to a variable,a string read from a file

Status
Not open for further replies.

gvidos

Programmer
Jul 24, 2002
17
0
0
GR
Hi,

How can I "create" a string filename fo a file by concatenating to a first sub-string the string read as the first line of a file?

e.g.

file './servers' which contains the lines:

dilos
kos
milos

and want to create filename:

mgen_dilos for example

I need to do this in a loop (for each line of file servers,create the respective filename)

Anyone willing to help?
 
for name in `cat ./servers`
do
> mgen_${name}
done

The quote used is the acute quote on the top left of the keyboard.

Chris
 
Code:
while read name; do
  > "mgen_${name}"
done < ./servers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top