problem with print append to output file syntax

I'm trying to output the contents of the infile to the outfile using Append.
I will want to use append but the syntax doesn't seem to be working !
Input file (called a.txt) contains this:

a
a
a
b
b
b

I'm running shell script (called k.sh) from Unix command-line like this:

./k.sh . a.txt
#!/usr/bin/sh

infile="$1/$2"

awk '{print $0 >> newfile.txt}' $infile 

Error on command-line:

 syntax error The source line is 1.
 The error context is
                {print $0 >> >>>  newfile. <<< txt}
 awk: The statement cannot be correctly parsed.
 The source line is 1.

This is not the same code you posted in your other thread.

Yet, pertains to the same problem:

awk '{print $0 > "newfile.txt"}' $infile
1 Like