[CentOS] script help

Les Mikesell lesmikesell at gmail.com
Thu Jun 18 03:14:47 UTC 2009


chloe K wrote:
> Hi
> 
> I have a file. list.txt (two columns)
> 
> column1    column2 name        address
> 
> 
> I need to put in the letter file letter.txt eg:
> 
> Dear: Chloe Address: CA
> 
> Can I use this
> 
> for i `cat list.txt` | sed 's/Chloe/$i.1; /CA/$i.2/g' $i.letter.txt
> 
> Thank you for your help
> 

#!/bin/sh
while read NAME ADDRESS
do
sed -e"s/Chloe/$NAME/" -e"s/CA/$ADDRESS/" <letter.txt>$NAME.letter.txt
done <list.txt

Seems sort of fragile in that the name field can't have spaces.

-- 
   Les Mikesell
    lesmikesell at gmail.com



More information about the CentOS mailing list