Tuesday, April 30, 2024
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 18934  / 3 Years ago, wed, august 11, 2021, 4:35:33

I have a text file.



number 1_1 	 number1_2 	 etc
number 2_1 number2_2 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?


More From » command-line

 Answers
5

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



:%s/^[^ ]* //



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.


[#24988] Thursday, August 12, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rryble

Total Points: 489
Total Questions: 121
Total Answers: 119

Location: Marshall Islands
Member since Mon, May 31, 2021
3 Years ago
;