Re: substituting space with a pipe in a text file

From: Alexis Huxley (ahuxley_at_gmx.net)
Date: 12/30/04


Date: Thu, 30 Dec 2004 08:41:32 +0100


> 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