I am trying to change a file that looks like this:
file, announcement,date, server, server01, server02, server06, file04, rec01, rec04, rec03... etc
into a vertical file like this:
file
announcement
date
server
server01
server02
server06
The file does not have to be sorted alphabetically. I tried a number of ways, but the comma is giving me trouble. Can someone suggest?
Hello newbie2010,
Could you please try following, please use code tags for commands/codes/inputs you are using in your posts too as per forum rules.
awk '{gsub(/\, |\,/,"\n",$0);print}' Input_file
Thanks,
R. Singh
a more detailed/granular sample input and the desired output would be helpful - a given mnemonic sample leaves room to interpretation......
Aia
5
% perl -pe 's/\s?,\s?/\n/g' file.test
file
announcement
date
server
server01
server02
server06
file04
rec01
rec04
rec03... etc
You could also try:
awk -F', *' '$1=$1' OFS='\n' file
which, with your sample input, produces the output:
announcement
date
server
server01
server02
server06
file04
rec01
rec04
rec03... etc
If you want to try this on a Solaris/SunOS system, change awk
to /usr/xpg4/bin/awk
.