LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Removing Txt file lines using Linux Scripts

[ILUG] Removing Txt file lines using Linux Scripts

Burke, Gary : GIG IS&T Gary.Burke at guinness.com
Fri Mar 31 15:59:54 IST 2000


]> 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

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
like...

^N^N^N^N^N^K^K^K^K^K^K^X^S^X^C

and use a command line

emacs filename < keystrokesfile


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.



Gary
**********************************************************************
This e-mail and any attachment contains information which is private
and confidential and is intended for the addressee only.
If you are not an addressee, you are not authorised to read, copy or 
use the e-mail or any attachment.  
If you have received this e-mail in error, please notify the sender 
by return e-mail and then destroy it.
**********************************************************************




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


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!
RSS Version
Powered by Dell