gack! I've been doing this a lot lately — correcting
my own postings! — not sure why the sudden surge of
dumbwittery... maybe reducing the alcohol has affected
my brain? ;-\
anyways, several corrections (and yes, I know Philip
took the advice of the multitude not to use `sed')....
| Date: Mon, 16 May 2005 15:53:49 +0200
| From: Brian Foster <blf at blf.utvinternet.ie>
| > From: "Philip Trickett (List)" <phil-ml at techworks.ie>
| > Date: Mon, 16 May 2005 12:20:39 +0100
| >[... wants to print 5th value in a CSV file with sed(1) ...]
|
|[... other tools are better, but using a `sed' with EREs ...]:
|
| sed -e 's/^\([^,]*,\)\{4\}//' -e 's/,.*$//' # NO CHANGE
|
| that [ uses ] two sed `s'-commands. the first deletes
| the initial four fields [ ... ]. the second then
| [ deletes ] any sixth and subsequent fields (which, after the
| first command, are now the second and subsequent).
|
| the only(?) glitch is if the line has less than
| 5 fields, the [ first ] one is printed. [ ... ]
--
Experienced (20+ yrs) kernel/software Eng: | Brian Foster Montpellier,
• Unix, embedded, &tc; • Linux; • doc; | blf at utvinternet.ie FRANCE
• IDL, automated testing, process, &tc. | Stop E$$o (ExxonMobile)!
Résumé (CV) http://www.blf.utvinternet.ie | http://www.stopesso.com
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!