I have the following script set up and working properly in bash. It basically copies a set of lines which match "AS1100002" from one file and replaces the same lines in another file.
awk -vN=AS1100002* 'NR==FNR { if($1 ~ N)K[$1]=$0; next }
{ if($1 in K) $0=K[$1]; print }' $datadir/file1 $datadir/file2 > $datadir/file2.new
But in csh I get the following error when running:
That should not be the case nor should it happen, unless you copied/paste the code you submitted: When using GUI the selection of 2 lines is understood "AS" 2 lines and will put a en of line and the end of first line... You remove it and Im sure it works... e.g. in vi you use J to join both lines...
awk -vN=AS1100002* 'NR==FNR { if($1 ~ N)K[$1]=$0; next }\
{ if($1 in K) $0=K[$1]; print }'\
$datadir/file1 $datadir/file2 > datadir/file2.new