vi command to find and delete all lines beginning with a character
Anyone know how I can delete all of the lines in a file that begin with some arbitary character?
Been poring over the vi documentation and various online sources of info, but I can't figure it out.... -geo |
You could always use Grep in reverse mode, within or without Vim, such as
Code:
grep -vE ^# inputfile > outputfile Cheers, mj |
Hey great thanks. Doesn't need to be within vi as long as it works.
-geo |
Great :)
If you're a real Vim afficionado, you would of course just run it from within the shell mode of Vim. Cheers, mj |
Just use ex mode -
:g/^x.*$/d with 'x' being your arbitrary character. |
Thanks. I'll try that too. Just starting to learn a bit more about what can be done in vi....
-geo |
A decade or so ago, I was pretty good with vi. I do not believe you can do what you want with vi. You might be able to with sed, however.
|
Quote:
|
Speaking of sed, I actually messed that up slightly -
:g/^x/d is all that's necessary. d will delete all of the addressed lines, so the rest is unnecessary - I guess I put that from habit because I use sed and 's' a lot. Either one works, but it's wasted typing in this case. :) |
All times are GMT -5. The time now is 07:14 AM. |