It almost looks like you just need
echo "$2\n$3\n">>$nfile
thines01
Postaholic
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
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,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
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 Master Poster
657 posts since Feb 2011
Reputation Points: 201
Solved Threads: 124