Use the fields
CLI command as a modern replacement for awk
+ cut
.
With fields you specify which columns of text you want, in a flexible format.
The fields
command can be installed via Go by running
$ go install github.com/shoenig/fields/cmd/fields@latest
$ fields 3 <<< "a b c d e f g"
c
$ fields -- -3 <<< "a b c d e f g"
e
$ fields 1,-1,2,-2 <<< "a b c d e f g"
a g b f
$ fields 4: <<< "a b c d e f g"
d e f g
$ fields -- -2: <<< "a b c d e f g"
f g
$ fields :2 <<< "a b c d e f g"
a b
$ fields :-2 <<< "a b c d e f g"
a b c d e f
$ fields 2:5 <<< "a b c d e f g"
b c d e
$ fields 1,2,-2,3:5,2:,:-3 <<< "a b c d e f g"
a b f c d e b c d e f g a b c d e
The github.com/shoenig/fields
module is always improving with new features
and error corrections. For contributing bug fixes and new features please file an issue.
The github.com/shoenig/fields
module is open source under the MIT license.