Burke, Gary : GIG IS&T writes:
> ]> Can any one tell me , how to remove some 5-6 lines
> ]> from a big text file using linux scripts
> ] ed vi sed tail head awk perl python grep. And I'm sure I missed
> ] another dozen.
>> I can think of a few not very nice ways that may work, but I'm sure there
> are better ways.
>> Firstly, if you know the exact text of the lines you want to remove, then
> try something like
>> cat filename | grep -v "first line" | grep -v "second line" | .... | grep -v
> "last line" > newfilename
Argh. Useless use of cat.
egrep -v "first line|second line|..." filename >newfilename
> But that's horrible. Another way would be to use vi or emacs. If you know
> which lines they will be all the time, then you can store the keystrokes you
> requires in a file. I know using Emacs you can use ^Q and a character (like
> ^X) and it will put a ^X into the buffer instead of Email trying to
> understand it. I'm sure this is possible in vim. So, you would have a file
>> and use a command line
>> emacs filename < keystrokesfile
There is sucha thing as ed scripts ...
> Though that is also very very messy.
>> There are probably much better ways, and I'm sure someone will come up with
> a few better ones for you.
It really depends on what exactly he wants to do, and what the input looks
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!