Singled line records

Hi, :cool:
I�m new on this Linux groups and like to learn more,
Right now, I�m working on a project (personal) and have a question fallowing problem
I�m making a bash script to read many files and extract some fields and separate them according certain criteria, let say a have a big file with records like these
210,linux
211,linux
220,windows
230, solaris
240, linux
250,ubuntu
Now I made an awk process to make 4 different files:
Linux.txt
210,linux
211,linux
212, linux ....219
Windows.txt
220,windows...220
Solaris.txt
230.solaris...239
Ubuntu.txt
250,ubuntu...259
Here is where the fun begin, I already remove field 2 from each file, but can not make all records on a singled line, I need them all like look this :b:
Linux.txt
210,211,212,...219
Windows.txt
220...229
Solaris.txt
230,...230
Ubuntu.txt
250,...259

Any help would be appreciated. :confused:

Zopilota

Looks like homework, what kind of project is this?

Can you show us what you have attempted so far?

Hi,

Hope it was a homework. :slight_smile:

This is what I have so far.

while read line ;do
    grep $line $fileTre | awk 'BEGIN {FS = ","} ; {print $59}' >> $line'_'$fileFor
done < $fileTwo

With this I open a file $fileTwo for Reading and made a loop
Get $line value whish is normali a name (let say linux in first place)
from $fileTree and extract only field $59 (210, 211�219) and make a new file $line_$fileFor wich would be linux_fileFor for example.

Ok, I hope I'm wrong.

awk -F, '{a[$2]=a[$2]?a[$2]FS$1:$1}END{for(i in a){print a > i ".txt"}}' file

If this is new for you, you can have a read of The GNU Awk User's Guide.

Thank you very much, it realy works.

:slight_smile:

Zopilota