Request for file read option in Unix shell scripting

Hi Friends,

I would like to read all the record from one txt file to other file txt

For example I have two txt file a.txt and b.txt. I need to read a.txt record by record and I need add the system date @ end of each record before moving it to b.txt. Could you please share the coding for this, I am very much new to this language. Thanks in advance.

For Example:
a.txt file contains the below record
Sample text record 1
Sample text record 2
Sample text record 3
Sample text record 4
Sample text record 5
Sample text record 6

After running my script it should generate b.txt as below
Sample 06/01/2011 text record 1
Sample 06/01/2011 text record 2
Sample 06/01/2011 text record 3
Sample 06/01/2011 text record 4
Sample 06/01/2011 text record 5
Sample 06/01/2011 text record 6

Regards,
Vinoth R

Try this:

awk '{$1=$1" 06/01/2011"}1' a.txt > b.txt
DATE=`date +%m/%d/%Y`
while read A B
do
        echo $A $DATE $B
done < a.txt > b.txt

This one will do the job as well (assuming all the lines start with "Sample "):

sed "s|^Sample \(.*\)|Sample $(date +%m/%d/%Y) \1|g" a.txt > b.txt

You don't even need a back reference here :

sed "s|^Sample |&$(date +%m/%d/%Y) |" a.txt >b.txt