Touch New File with First Line

I am interested in creating a new file from a KSH script where the first line is printed. I know how to create the file, but creating with a pre-defined first line is what I need help with.

My code below creates the file, but how do I accomplish that and do it so that when I open that txt file it has a number 1 or statement in the first line?

filebegin="FILE_"
filedate=`date +%m-%d-%Y`
fileend=".txt"
createfile=$filebegin$filedate$fileend
echo $createfile
touch $createfile

Hi.

I think this is what you mean?

filebegin="FILE_"
filedate=`date +%m-%d-%Y`
fileend=".txt"
createfile=$filebegin$filedate$fileend
echo $createfile
echo 1 > $createfile

That's it! Thanks, works great.

Shorter :wink:

echo 1 > FILE_`date +%m-%d-%Y`.txt

Yes... to cut a long story short(er) :slight_smile:

LOL :b: