Skip to content
This repository was archived by the owner on Jun 5, 2024. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions gnu_awk.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,19 @@ $ printf ' a ate b\tc \n'
a ate b c
$ printf ' a ate b\tc \n' | awk '{print $1}'
a
$ printf ' a ate b\tc \n' | awk '{print NF}'
4
$ printf ' a ate b\tc \n' | awk '{print $NF}'
c
$ # same behavior if FS is assigned to single space character
$ printf ' a ate b\tc \n' | awk -F' ' '{print $1}'
a
$ printf ' a ate b\tc \n' | awk -F' ' '{print NF}'
4
$ printf ' a ate b\tc \n' | awk -F' ' '{print $NF}'
c

$ # for anything else, leading/trailing whitespaces will be considered
$ printf ' a ate b\tc \n' | awk -F'[ \t]+' '{print $2}'
a
$ printf ' a ate b\tc \n' | awk -F'[ \t]+' '{print NF}'
6
$ printf ' a ate b\tc \n' | awk -F'[ \t]+' '{print $NF}'

```

* assigning empty string to FS will split the input record character wise
Expand Down