[ale] regex assistance

JD jdp at algoloma.com
Thu Jan 23 14:45:17 EST 2014


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


More information about the Ale mailing list