Regular expression to remove the last column from a channel delimited file

I have a file with 1000 records and 131 columns, the columns are channel-limited. There is no pipe at the end, so the format is something like.

2010-10-04 | Safety | AMEND | 20162214 | ... more columns ... | Bloomberg

How to delete the last column of a file in Vim?

+3
source share
4 answers

You need

%s/|[^|]*$// 

Note. I use [^|]*to resolve an empty column.

+6
source

This regex will catch the last column: \|[^|]+$

+3
source

:

:%s/.*\zs|.*//
+1

cut awk

0

Source: https://habr.com/ru/post/1768285/


All Articles