info
-
remove or
cut out
sections of each line of a file or files -
when invoking
cut
use -b -c or -f option, but only one of them
demo
-
cut field
-
second-through-fourth
field of each line$ cut -f 2-4 data.txt
-
first-through-second
andfourch-through-fifth
field$ cut -f 1-2,4-5 data.txt
-
third and every field after it
$ cut -f 3- data.txt
-
-
specifying a delimiter other than tab
-
cut by
:
$ cut -f 1 -d ':' data.txt
-
delimited by a space
$ cut -f 1,3 -d ':' --output-delimiter=' ' data.txt
-
delimited by
tab
$ cut -f 1,3 -d ':' --output-delimiter=$'\t' data.txt
-
-
character
-
output third character
$ cut -c 3 data.txt
-
output first three characters
$ cut -c 1,3 data.txt
-