Wednesday, February 15, 2023

Print Column Until End of Line in Linux Terminal

I have a document named mydoc.txt which contains below lines

local STAFF
local STUDENTS
local CONTRACT TEACHERS

I need to print all except the first column. To accomplish that, I can use this command
$ cut -f2- -d ' ' mydoc.txt

Where -d is delimiter, and -f is field number. The hyphen after -f2 is to tell 'cut' to print field number 2 until the end of line.

No comments: