1753463 Members
4634 Online
108794 Solutions
New Discussion юеВ

script to parse a file

 
Senthil Prabu.S_1
Trusted Contributor

script to parse a file

Hi all,
I have a file with following datas;

backup:ce1
core:ce3
backup:ce5
core:ce7

Now, I want to operate on this file, so that my script prints a formatted ouptut like
backup : ce1 :ce5
core: ce3 : ce7

Can anyone help me with this...


Thanks,
Senthil
One man's "magic" is another man's engineering. "Supernatural" is a null word.
2 REPLIES 2
Senthil Prabu.S_1
Trusted Contributor

Re: script to parse a file

Hi all,
I got the answer.

It is;
sort group | awk -F: '{ if ( $1 == last ) { print ":"$2;} else { printf $0; } last=$1;}'
backup:ce1:ce5
core:ce3:ce7



so, closing the thread
One man's "magic" is another man's engineering. "Supernatural" is a null word.
Senthil Prabu.S_1
Trusted Contributor

Re: script to parse a file

I found anw, so closing
One man's "magic" is another man's engineering. "Supernatural" is a null word.