Hello,
I have a text file with space and tab (mixed) delimited file and need to convert into CSV.
# cat test.txt
/dev/rmt/tsmmt32 HP Ultrium 6-SCSI J3LZ 50:03:08:c0:02:72:c0:b5 F00272C0B5 0/0/6/1/1.145.17.255.0.0.0 /dev/rmt/c102t0d0BEST
/dev/rmt/tsmmt37 HP Ultrium 6-SCSI J3LZ 50:03:08:c0:02:72:c0:97 F00272C097 0/0/6/1/1.145.17.255.4.0.0 /dev/rmt/c103t0d0BEST
/dev/rmt/tsmmt48 IBM ULT3580-TD3 5AT0 5458623002 0/0/6/1/1.145.0.255.8.0.0 /dev/rmt/c72t0d0BESTn
/dev/rmt/tsmmt53 IBM ULT3580-TD3 5AT0 5458623006 0/0/6/1/1.145.0.255.8.0.1 /dev/rmt/c72t0d1BESTn
I tried the below
sed 's/\t/ /g' test.txt |sed 's/ */ /g' |sed 's/ /,/g' >test.csv
It works but unfortunately, few fields have blank values and with above technique, values are getting shifted to left. Please advise.
Also, how to find out if a file has spaces or tabs, do I need to use an editor which shows control characters?
Thanks in advance!