Reputation: 2615
I have a file in the following format:
s1,23,789
s2,25,689
and I would like to transform it into a file in the following format:
s1 23 789
s2 25 689
i.e 6 white spaces between the 1st and 2nd column and only 3 white spaces between the 2nd and 3rd column?
Is there a quick way of pulling this off using sed or awk?
Upvotes: 1
Views: 570
Reputation: 1
just for future seekers, I used the answer from Naumann and modified it to for my own use. My purpose is to remove commas between two columns and put a white space there. The following worked for me:
awk -F, '{ print $1,$2 }' n64215_my_file_name.txt > log_new_file_name.txt
Upvotes: 0
Reputation: 8164
you can try with sed
sed -r 's/(\S+),(\S+),(\S+)/\1 \2 \3/g' file
or awk
using Modifiers for printf Formats
awk -vFS="," '{printf "%2s%8s%5s\n",$1,$2,$3}' file
you get,
s1 23 789
s2 25 689
Upvotes: 4