Skip to Content
gnux

-f, --fields

Select only these fields; also print any line that contains no delimiter character, unless the -s option is specified.

An option of cutx.

Usage

cutx -f string OPTION... [FILE]...
cutx --fields=string OPTION... [FILE]...

Details

ShortLongValueDefaultMeaning
-f--fieldsstringselect only these fields; also print any line that contains no delimiter character, unless the -s option is specified

Examples

cutx -f 1 data.tsv
cutx -d : -f 1,7 /etc/passwd
cutx -d , -f 2-3 people.csv
cutx -d , -f 3- people.csv

Drop the second column, keeping the rest

cutx -d , -f 2 --complement people.csv

Convert a CSV file to TAB-separated output

cutx -d , -f 1- --output-delimiter=$'\t' people.csv

Join the selected columns with a custom separator

cutx -d : -f 1,3 --output-delimiter=' -> ' passwd.txt

Skip lines that contain no delimiter, such as comments

cutx -s -d = -f 2 settings.ini

Pull one field out of a command's output

echox 'key=value' | cutx -d = -f 2

Process NUL-separated records

cutx -z -d / -f 1 paths.lst

Help in the terminal

gnux help cutx --fields

On this page