Take the 2-minute tour ×

I have a text file.

number 1_1 \t number1_2 \t etc
number 2_1 \t number2_2 \t etc

I want to remove the first column of this file (corresponding to number1_1, number2_1 etc, ie the numbers before the first tab for each row). I read this post that proposes a solution to delete the first column (see Peter's answer). However, it doesn't work for me as the numbers have different sizes and I cannot repeat the operation to delete the first column. How can I do then?

share|improve this question
Do you want a vim specific solution? –  i08in May 26 at 9:48
preferably, but not necessarily (what else do you propose?) –  bigTree May 26 at 9:48
@bigTree do you want command line answers? –  Avinash Raj May 26 at 10:00
@AvinashRaj Command line answers would be good thanks –  bigTree May 26 at 10:04

3 Answers 3

up vote 4 down vote accepted

This should delete all chars before and including the 1st tab on any line:


Command line cut:

cut -f 2- {filename.txt} > {filenamenew.txt}

cut defaults to tabs; if you want something else like a space add -d " ". -f is fields to copy over. 2- means all from (and including) column 2.

share|improve this answer

Through awk,

awk -F"\t" '{print FS,$2}' file > newfile

It cuts the first column and prints only the remaining tab and second column.

Through sed,

sed -r 's/^([^\t]*)\t(.*)$/\t\2/g' file > newfile
share|improve this answer


On every line (%), replace (<code>/<em>ORIGINAL</em>/<em>REPLACEMENT</em>/</code>) the first occurrence of “non-tab characters ([^\t]) in any numbre (*) followed by a tab\t” by nothing. You can type <kbd>Tab</kbd> instead of\t`.

Alternatively you can match the shortest sequence of characters (.\{-}) ending in a tab. .*\t would match the longest match for .*, so it would match all but the last column; .\{-} matches the shortest match which is the first column.


share|improve this answer

Your Answer


