Columns - the end
James N McClatchey
jnm at safn2.saf.com
Thu Feb 22 09:15:55 EST 1996
Thanks to all who answered. It is interesting to me how often strings
and string manipulation are the subject of problems and questions in
the C-Unix environment.
To summarize:
Problem: convert "every | good | boy | does | fine" to
every
good
boy
does
fine
Answers: Consensus seemed to be to use sed to strip whitespace.
Then to add newlines:
1 ) gawk
awk -F\| '{for (i=0;i<=NF;i++) {printf "%s\n,$i}}'
2) tr
tr '|' '\012'
3) fmt
sed 's/|//g' | fmt -1
I guess I liked #2 myself. #1 seemed a little obtuse. #3 might cause
problems with fields that contained whitespace in their midst.
Thanks again!
Regards - Jim
--
James N. McClatchey P.E. (Southern Aluminum Finishing Co, Atlanta, GA, USA)
Architectural Aluminum. Custom Fabrication. Paint, Powder Coating, Anodizing
mailto:jnm at saf.com Voice: 404-355-1560 Fax: 404-350-0581
http://www.saf.com SAF Home Page
More information about the Ale
mailing list