I know this should be very simple but due to some reason I am not able to get this working.
say I have a simple file with multiple columns of data, I just want to get second column and remove other columns, while I have that file opened in vim. As answered here, I use following in vim:
:%!cut -f2But it just shows following, but contents of file is still same.
6 lines filtered
See the screenshots attached:
I want to change the contents of file and have only second column there. I am using Mac.
11 Answer
The cut command assumes a tab delimited file. So you should first replace the spaces with a tab. The following will do this for you:
:%s/\s\+/\t/gfollowed by the cut command that you already figured out :)
:%!cut -f2 2