[CentOS] script help

Thu Jun 18 08:21:43 UTC 2009
Mohan <mk at nerdplanet.co.uk>

Hi

If your file has only 2 columns and there is no space exists in 2nd 
column then you can use this script

#!/bin/sh
FILE="list.txt"
OUTPUT="out.txt"
while read VAL

do
VAL1=$(echo $VAL | awk '{print $1}' )
VAL2=$(echo $VAL | awk '{print $2}' )

echo "DEAR: $VAL1" >> $OUPUT
echo "DEAR: $VAL2" >> $OUPUT
echo " ">> $OUTPUT

done<$FILE

if you have spaces in between your 2nd column you might have to format 
the file using awk/sed
so that there would be a valid delimeter between column1 and column2

column 1| column2 here we can use '|' as the delimeter and change awk 
statement
to awk -F '| ' '{print $1}' or something like this.

--
Regards,
Mohan.



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
>  
>  
>  
>  
>  
>
>
> ------------------------------------------------------------------------
> Looking for the perfect gift?* Give the gift of Flickr!* 
> <http://www.flickr.com/gift/>
> ------------------------------------------------------------------------
>
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.centos.org/pipermail/centos/attachments/20090618/39a4d690/attachment-0005.html>