Tools‎ > ‎Ubuntu/Linux server‎ > ‎

Extract columns from file


# print column 2 of file 'table.csv'
cut -f 2 table.csv
# print output to new file
cut -f 2 table.csv > column2.txt

# print column 3 and 4 of file 'table.csv'
cut -f 3,4 table.csv


# switch columns 3 and 4
paste <(cut -f4 table.csv) <(cut -f3 table.csv)

# get last column of a table (reverse text lines, cut first column; and reverse back)
cat mytable.csv | rev | cut -f 1| rev


See also: awk