Hi there,
Is there any option if I cat the following line from a file and than redirect to another as separate entries:
unixsrv1:unixsrv2:unixsrv3:mercury:mercury01:sunprd01:sunprd02:hpprod07:ibmprod43
output to file shoudld be:
unixsrv1
unixsrv2
unixsrv3
... and so on.
Your help is really appreciated.
echo 'unixsrv1:unixsrv2:unixsrv3' | tr ':' '\n'
Input file:-
$ > cat 123.txt
unixsrv1:unixsrv2:unixsrv3:mercury:mercury01:sunprd01:sunprd02:hpprod07:ibmprod43
$ >
Command:-
$ > cat 123.txt | tr -s ":" "\n" > 123_1.txt
$ >
Output:-
$ > cat 123_1.txt
unixsrv1
unixsrv2
unixsrv3
mercury
mercury01
sunprd01
sunprd02
hpprod07
ibmprod43
$ >
Thanks,
Karthik.
Excellent !! you guys are the best helpers.
A quick ?, how can I get rid of the duplicate entries: This is what I have now;
unixsrv1
unixsrv1
.
.
.
unixsrv1 (20 entries)
same for the other hosts.
I ran the following command but no luck!
# cat file | sort | uniq -d
Thanks again guys.
do not use the -d option of uniq command
edit: so this should do the job for you: cat file | sort | uniq
Thanks a lot Yogesh !! it works.