For Programmers: Free Programming Magazines  


Home > Archive > Unix Shell Programming > December 2004 > Re: substituting space with a pipe in a text file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: substituting space with a pipe in a text file
Alexis Huxley

2004-12-30, 8:57 am

> AAA BBB CCC DDD EEE 123
> ADSSD SFDS ADSF FDDSF FDSFS
>
> I want to replace the spaces in the input text file with a pipe to get
> a resulting file like this
>
> AAA|BBB|CCC|DDD|EEE|123
> ADSSD|SFDS|ADSF|FDDSF|FDSFS


For sed, you want to substitute (s) your 'source' pattern which is at
least one space, or put another way one space followed by any number
of spaces ( *) for your 'target' pattern which is a pipe (|) and
you want do make the substitution multiple times on a line, or, in
sed terminology, "globally" (g).

Alexis
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com