- delimiter:
-d:
,-d' '
- field:
-f3
,-f1-4
,-f3-
- invert:
--complement
Get the third field delimited by a :
:
echo "foo:bar:baz:bat" | cut -d: -f3
# output: "baz"
Invert the selection with --complement
to get eveything but the third field:
echo "foo:bar:baz:bat" | cut -d: -f3 --complement
# output: "foo:bar:bat"
Get fields 2-3, inclusive:
echo "foo:bar:baz:bat" | cut -d: -f2-3
# output: "bar:baz"
Get field 3 and every field after it:
echo "foo:bar:baz:bat" | cut -d: -f3-
# output: "baz:bat"
Get field 2 and every field before it:
echo "foo:bar:baz:bat" | cut -d: -f-2
# output: "foo:bar"