Help needed for script

Hi,
I have a big list like this -->

3285
3289
328D
3291
3295
3299
329D
32A1

I need to make it like -->

3285|3289|328D|3291|3295|3299|329D|32A1

Please suggest. This is Linux OS.

One way:

awk 's{printf("%s|",s)}{s=$0}END{print}' file
1 Like

Thanks Franklin, it worked. You made my life easy :slight_smile:

Good for you. That's no help if you want to do that automatically in a shell, instead of hand-editing in a GUI.

try also:

awk '$1=$1' RS= OFS="|" infile

on solaris the following works:

paste -s -d"\d" filename | sed 's/d/|/g' 

The previous awk was cool!
Solaris /bin/awk:

awk '$1=$1!=""' RS= OFS="|" file

Solution using sed

sed -e ':l' -e 'N' -e '$!bl' -e 's/\n/\|/g' filename

... but the OP said big file and Linux.

awk '1' ORS="|" file