help-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shift and rotate in gawk


From: J Naman
Subject: Re: Shift and rotate in gawk
Date: Tue, 30 Apr 2024 12:48:05 -0400

Why not avoid all the complexity, rebuilding $0, etc.:
str = ""
for (i=2; i<=NF; i++)  { str = str $i OFS}
str = str $i   # no trailing OFS for last one
print str
# or $0 = str ... etc
}
PS: FS = .. OFS = ... IMHO belong in a BEGIN{} block
By the time you set them in your example, the FIRST record
uses the default FS and only the second and subsequent recs
use your custom FS.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]