Hi All ,
I am facing a small challenge i need unix command to remove space as well as replace "|" to "," in a csv file .
original file :
A | B | c | D
E | F | G | H
I | J | K | L
P | M | N | O
Expected o/p:
A,B,c,D
E,F,G,H
I,J,K,L
P,M,N,O
Hi All ,
I am facing a small challenge i need unix command to remove space as well as replace "|" to "," in a csv file .
original file :
A | B | c | D
E | F | G | H
I | J | K | L
P | M | N | O
Expected o/p:
A,B,c,D
E,F,G,H
I,J,K,L
P,M,N,O
sed 's/ | /,/g' infile
Try:
awk '{$1=$1; gsub(/\|/,",")}1' OFS= file
$ cat file
A | B | c |D
E |F | G | H
I | J | K | L
P | M | N | O
$
$ awk '{$1=$1; gsub(/\|/,",")}1' OFS= file
A,B,c,D
E,F,G,H
I,J,K,L
P,M,N,O
You may Try
$ cat <<eof | sed "s/[[:space:]]//g;s/|/,/g"
A | B | c | D
E | F | G | H
I | J | K | L
P | M | N | O
eof
A,B,c,D
E,F,G,H
I,J,K,L
P,M,N,O
Thank you sooooooooooooooo much all of you for the immediate response :):):)