Re: sed split on pipe

[email protected] ("Jay Savage")
Newsgroups perl.beginners
Message-ID <[email protected]>
On Tue, May 6, 2008 at 7:27 AM, Jack Butchie <[email protected]> wrote:
> Have been googling for some time now and every command I tried fails.  I
> want to use sed from the command line or use it in a windows batch file to
> split on a pipe delimited file, windows server. The examples  have \n as the
> carriage return code, but all that happens is the pipe is replaced by the
> letter n.
>
> the file has a space between each line
>
> CALL|TITLE|URL LINK|
>
> CALL|TITLE|URL|LINK

Maybe your files have windows line endings, or you haven't accounted
for the the examples assuming a unix shell, which handles quotes
differently?

Sine this is a Perl list, though, perhaps you would like to try using
Perl instead of sed? Something along the lines of the following should
work.

perl -F'|' -lane 'print join "\n", @F unless /^\s*$/'
# or
perl -lpane 's/|/\n/'

On Windows you may need to change the quotes around.

HTH

-- jay
--------------------------------------------------
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org

values of β will give rise to dom!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.