Home » Questions » Computers [ Ask a new question ]

Replace line with only part of the line

Replace line with only part of the line

I have a large table from Wikipedia (from the wiki source), and I want to extract a single column, I have it open in vim, and what I want to extract looks something like this

Asked by: Guest | Views: 62
Total answers/comments: 2
Guest [Entry]

"I would cut the content out first, then open it in vi:

cat wikifile.txt | cut -d \| -f 4 > foo
vi foo

Two steps, but two steps I can always remember without much thought."
Guest [Entry]

"Is this what you want :

1,$ s/^\(.*\[\[\)\(.*\)\(\]\].*\)$/\2/

It check from the begin of the line to [[ -> put it in atom 1, the sentence -> atom 2, the end of line -> atom 3.

Then just display atom 2."