displaying a column in horizontal line separated by ', '

cat my.log
blah blah blah
< 1  djfh jsdfhk jksdfh
< 2  dshkfl opeir pqowi
< 4 khasd wouipeui

say i am perfroming some action similar to below...

cat my.log | egrep "<" | awk -F' ' '{print $2}' | grep -v "[A-Za-z]"

it gives output as below

1
2
4

is there anyway to modify above same command so that output is displayed like below

[CODE]1, 2, 4/CODE]

Hi

$ awk '/</{print $2}' my.log | paste -s -d,
1,2,4

Guru.

1 Like

thanks a lot.. the code is working good :-). by chance is there anyway to output with space.. say like 1, 2, 4.. otherwise above is fine :slight_smile:

try this too

tr "\n" " ," < vivek.txt > vivek_chgnd.txt
awk '/</{print OFS $2}' my.log | paste -s -d,

--ahamed