[ale] regex assistance

chip chip.gwyn at gmail.com
Thu Jan 23 14:52:17 EST 2014


# cat test
00
01
02
03
04
# cat test | tr '\n' '|'
00|01|02|03|04|
#

I think 'tr' will likely solve this to your needs, basically replace a line
feed with a '|'

--chip


On Thu, Jan 23, 2014 at 2:45 PM, JD <jdp at algoloma.com> wrote:

> I would do it inside vi in 2 steps.
> * replace the EOL with a | or ' |' depending whether these entries have a
> space
> after or not
> * replace the EOL with "nothing" to merge all the links.  cnt-v then cnt-m
> will
> enter a newline char.
>
> This can be done with sed, perl, awk, python ...
>
> If the numbers are in order, it would be easier to recreate them with a
> script.
> #!/usr/bin/env bash
> LINE=01
> for (( i=02; i<31; i++)) ; do
>    LINE="$LINE | $i"
> done
> echo $LINE
>
> I'll leave the problem that this doesn't solve there.
>
>
>
>
>
> On 01/23/2014 01:09 PM, brock at quantifier.org wrote:
> >
> > Hello, linux neighbors,
> >
> > I am a regular expression amateur.  I have a text file with a bunch of
> numbers,
> > which looks like this:
> >
> > 00
> > 01
> > 02
> > 03
> > 04
> >
> > and I need to convert it, so that each number is on one line, and
> separated with
> > the | pipe, so:
> >
> > 00 | 01 | 02 | 03 | 04
> >
> > If it's not too much trouble, could someone script-fu something up to
> solve my
> > problem?
> >
> > Thanks much,
> > Robert
> > _______________________________________________
> > Ale mailing list
> > Ale at ale.org
> > http://mail.ale.org/mailman/listinfo/ale
> > See JOBS, ANNOUNCE and SCHOOLS lists at
> > http://mail.ale.org/mailman/listinfo
>
>
> --
> JD Pflugrath
>  Value | Results
> Direct: +001.678.685.8882
> Ofc: 1.866.963.2546
> Managing Director
> Algoloma Systems, LLC
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>



-- 
Just my $.02, your mileage may vary,  batteries not included, etc....
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20140123/92c79441/attachment-0001.html>


More information about the Ale mailing list