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!
On Wed, Jun 17, 2009 at 11:16 AM, Brianemaillists@beckerspace.com wrote:
Can I use this
for i `cat list.txt` | sed 's/Chloe/$i.1; /CA/$i.2/g' $i.letter.txt
Why don't you just try it and see if it works?
There _is_ that, but it won't....
:-)
mhr
There is going to be a problem with your sed line as the semi-column is not helping matters. You can try using a database for easy retrieval with your script. I hope it puts you on the way.
On Wed, Jun 17, 2009 at 7:16 PM, Brian emaillists@beckerspace.com wrote:
Can I use this
for i `cat list.txt` | sed 's/Chloe/$i.1; /CA/$i.2/g' $i.letter.txt
Why don't you just try it and see if it works? _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
On Wed, Jun 17, 2009 at 10:54 AM, chloe Kchloekcy2000@yahoo.ca 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
I've never seen any shell or sed syntax that allows you to subscript a line like this. You should read up on awk, although there is no simple way to do dual file processing along these lines. (An awk script for this would need to know it has two files to process and read in the first one, then print it with replacements from the second one.)
Also, if the above were to work, it would be "for i in `cat...." - the "in" is part of "for" syntax....
Man pages are really handy for this sort of thing....
HTH
mhr
On Wed, 17 Jun 2009 11:16:58 -0700 MHR wrote:
I've never seen any shell or sed syntax that allows you to subscript a line like this. You should read up on awk, although there is no simple way to do dual file processing along these lines.
Easy way to do this with awk is to have the first part of the script use awk to get the name and address. and then use them as arguments to a second invocation of awk.
Hi Chloe,
Please start by reading this: http://www.catb.org/~esr/faqs/smart-questions.html
On Wed, Jun 17, 2009 at 13:54, chloe Kchloekcy2000@yahoo.ca wrote:
I have a file. list.txt (two columns)
Separated by what? Tabs? Spaces? Can the fields themselves have spaces in them? Do you have many records, one per row? Please give a more informative example of the file you have...
I need to put in the letter file letter.txt eg:
Dear: Chloe Address: CA
Is that supposed to be a template? What are you trying to achieve? Replace "Chloe" with the first field and "CA" with the second field of the list.txt file? Create one file per row of list.txt?
If you ask vague questions all you will have are vague answers...
HTH, Filipe
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.
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@centos.org http://lists.centos.org/mailman/listinfo/centos
From: chloe K chloekcy2000@yahoo.ca
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
For single words space separated:
cat list.txt | while read LINE do set $LINE printf "Dear: %s\nAddress: %s\n" $1 $2 >> $1.letter.txt done
JD
Dear Chloe, John Doe`s script is a good start, even though it will work for single words space separated. The LINE Variable only passes the Arguments as single words to ($1 and $2 respectively). I will also work on something for you too...
On Thu, Jun 18, 2009 at 10:34 AM, John Doe jdmls@yahoo.com wrote:
From: chloe K chloekcy2000@yahoo.ca
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
For single words space separated:
cat list.txt | while read LINE do set $LINE printf "Dear: %s\nAddress: %s\n" $1 $2 >> $1.letter.txt done
JD
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos