cut from column X until the end of a tab delimited file
13,884
Solution 1
You're very close, but you're missing the dollar sign in there:
cut -d $'\t' -f5- file.txt
Solution 2
Not sure how to do it with cut but what I'd do if I had to print the fields from X to the end would be to use awk. Assume X = 2:
awk '{print $(NF - 2), $(NF - 1), $NF}' <<< "1 2 3 4 5 6"
which results in:
4 5 6
NF
is an awk reserved keyword that is a count of the number of fields.
Author by
Dnaiel
Updated on August 06, 2022Comments
-
Dnaiel almost 2 years
If I have a file with an unknown number of column but I know I want columns X til the end, is there an easy way to use cut for this?
Let us say X=5,
I used,
cut -f5- filename
but it did not work.Then I am trying to specify the -d'\t' and also it does not work.
Not sure what I am doing wrong.
Any help will be greatly appreciated.
thanks!