using AWK to make four column to one column

Gurus,

I have file contain following line.

,0113955056,,XAgent-Suspend
,0119418233,,XAgent-Suspend
,0102119078,,XAgent-Suspend

I want to make it one column file. How to do this using awk? Can anyone help with 'awk'

0113955056
0119418233
0102119078
awk -F, '{print $2}' file

You can also use cut :

cut -f2 -d, file

Jean-Pierre.

Thanks. AWK and Cut both are fine.

However, i have several files: file1,file2,file3...etc. which contains 4 column.

How can I make all those files contain in one column and filename will be same, using ONE AWK command?

file1,file2 four column change into one column file1,file2.

for i in *;do awk -F, {print $2} $i > $i.bk; mv $i.bk $i; done

Note : mv command is used, so your original file will be replace with one column

1 Like

If you have GNU sed:

sed -ri.bak 's/,([^,]*$)?//g' infile*