awk: simplify loop/fix missing filename (#3848)

client-spec/clarity
Vivek Kalyan 2020-02-18 05:26:27 +08:00 committed by GitHub
parent bb8a00ab9a
commit 897cff578d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -29,8 +29,8 @@
- Print all values starting from the third column:
`awk '{ s = ""; for (i=3; i <= NF; i++) s = s $i " "; print s }'`
`awk '{for (i=3; i <= NF; i++) printf $i""FS; print""}' {{filename}}`
- Print different values based on conditions:
`awk '{if ($1 == "foo") print "Exact match foo"; else if ($1 ~ "bar") print "Partial match bar"; else print "Baz"}'`
`awk '{if ($1 == "foo") print "Exact match foo"; else if ($1 ~ "bar") print "Partial match bar"; else print "Baz"}' {{filename}}`