aboutsummaryrefslogtreecommitdiff
path: root/challenge-096/abigail/awk/ch-1.awk
blob: dae5328b5f20ce05ed584327443f67e228397c11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/awk

#
# See ../README.md
#

#
# Run as: awk -f ch-1.awk < input-file
#

#
# AWK splits lines on whitespace, making each field available
# in $1, $2, ..., etc. So, we just print the fields in reverse,
# followed by a space (or a newline after the last/first).
#
{
    for (i = NF; i; i --) {
        printf "%s%s", $i, (i == 1 ? "\n" : " ");
    }
}