Assuming this is a one-off task, a method I often use is to open XEmacs
(or Emacs), and record a macro that does one line and replay that for
1. Start recording - C-X (
2. Go to start of line - C-A
3. Delete the first bunch of words - ESC-D, ESC-D, ESC-D, C-D
4. Search for the next quote - C-S "
5. Kill the rest of the line and clean up spaces and quotes - C-K, DEL,
6. Down to next line (C-N)
7. Stop recording - C-X )
Run the macro for the remaining lines & save. Obviously if you need to
keep running the script it's better off using a command-line tool.
Baldwin_James at emc.com wrote:
>> Quick question on Sed..I am brain-dead today...
>> I have a file for eg. below and want to keep only 1 column of data and
> delete the rest before and after that column;
> HOW? Using SED? How about a pre-filter of Grep before SED?
> (so, I want to make a file list and cut the rest of the data out)
>> BEFORE FILE:
>> Cannot Process File /usr/bin/12765 "The file is completely arsed. Can't
> Cannot Process File /usr/bin/123244 "The file is completely arsed. Can't
> Cannot Process File /usr/bin/134 "The file is completely arsed. Can't
> Cannot Process File /usr/bin/4334345 "The file is completely arsed. Can't
> Cannot Process File /usr/bin/12733 "The file is completely arsed. Can't
> Cannot Process File /usr/bin/1245981115 "The file is completely arsed. Can't
>> AFTER FILE:
> Cork maillist - Cork at linux.ie>http://www.linux.ie/mailman/listinfo/cork
Adam Lock - locka at iol.ie
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!