Hi consider the source file
R|field1|field2
using the print statement in awk prints it as
R field1 field2
Is there an easier way to print the whole line in its original format (i.e. with | delimiters) than doing print $1"|"$2"|"$3 ??
Thanks
Storms
The special OFS variable controls what awk's output separator is.
awk -F'|' '{ ... }' OFS='|' filename
You can even use this to transform lines with one separator into a different separator, but beware that awk won't actually alter the line until you write to the line or tokens in some way. A no-op like $1=$1
would do.
1 Like