Reputation: 11
Another awkward problem
I needed the following code to not add a carriage return at the end of each line.
awk -v coord_file="$txt_1" '
NR <= '$region1' {print $0}
NR > '$region1' && NR <= '$region2'{$6 = "" ; $7 = "" ; print $0}
NR > '$region2' {print coord_file}
{CONVFMT="%.10f"} ' input.sh > tmp
I found I needed to post process my file to remove carriage returns. All this is done in nested loops hence
IN=tmp
OUT=output"$[$i]$[$j]".sh
cat $IN | tr -d '\r' > $OUT
rm $IN
Upvotes: 1
Views: 2223
Reputation: 334
print adds a newline in awk. You can repress this by setting ORS (the Output Record Separator) to something else. Or you can use printf instead of print.
Upvotes: 1