I,
I have a file and i need to replace comma and blank space with comma and 0.
cat file.txt
a,5
b,1
c,
d,
e,4
I need the output as
cat file.txt
a,5
b,1
c,0
d,0
e,4
Please help guys.. a simple and short way.
I,
I have a file and i need to replace comma and blank space with comma and 0.
cat file.txt
a,5
b,1
c,
d,
e,4
I need the output as
cat file.txt
a,5
b,1
c,0
d,0
e,4
Please help guys.. a simple and short way.
What have you tried to solve this problem?
Try:
sed -e "s/,$/,0/" infile
I have tried to use sed command sed 's/,/,0/g', however, it changes the other values also..
I just need to replace the comma(,) with (,0)...
You would need to add a $ sign:
sed 's/,$/,0/g' file
Or try something like:
awk '{$2+=0}1' FS=, OFS=, file