Click to See Complete Forum and Search --> : shell script to merge two files


noshankus
03-25-2003, 10:09 AM
Hello,

Another n00b question =)


I want to write a shell script that takes the text froma text file a.txt and the text from b.txt (in reality more than two files), and add them to a seperate file including the relevant date.

I can do a version where I use some easy commands like cat, but I don't know how to seperate them by a new line:

cat a.txt >> c.txt
cat b.txt >> c.txt

However, the result groups the text together without seperating the text onto new lines in the created c.txt


Also, is there an easy way to introduce the date into the name of the file?

Such as first declaring a variable today = $date

cat a.txt >> '$date'.txt


Thank you very much for your help =)

Best regards,

stoe
03-25-2003, 10:31 AM
add a newline in between cats:

cat a.txt >> c.txt
echo >> c.txt
cat b.txt >> c.txt

date in a variable (see man date)

date=`date`

noshankus
03-26-2003, 04:48 AM
Much appreciated :D