It almost looks like you just need
echo "$2\n$3\n">>$nfile
thines01
Postaholic
2,433 posts since Oct 2009
Reputation Points: 447
Solved Threads: 408
Skill Endorsements: 7
So, narrowing it down to the simplest form:
SERVER:/export/home/user/science/shell$ more multiEcho.ksh
echo one > text.txt
echo two >> text.txt
echo three >> text.txt
SERVER:/export/home/user/science/shell$ more text.txt
one
two
three
...then replacing the hard-coded file name with a variable
SERVER:/export/home/user/science/shell$ more multiEcho.ksh
fileName=text.txt
echo one > $fileName
echo two >> $fileName
echo three >> $fileName
SERVER:/export/home/user/science/shell$ more text.txt
one
two
three
thines01
Postaholic
2,433 posts since Oct 2009
Reputation Points: 447
Solved Threads: 408
Skill Endorsements: 7
Either form should work correctly:
echo -e "$1\n$2\n" | cat >> $file
# Or
echo -e "$1\n$2\n" | cat - >> $file
In the second form it is explicit that STDIN is the input file.
Perhaps you should present a minimal working example of what fails so we can duplicate (including input/output and code).
L7Sqr
Practically a Posting Shark
866 posts since Feb 2011
Reputation Points: 253
Solved Threads: 155
Skill Endorsements: 7
Question Answered as of 1 Year Ago by
thines01,
cfajohnson
and
L7Sqr