Hi,
sorry for bothering with this easy problem but I can't understand...
I've a file like this:
"4","0x23a3"
"5","0x4234"
"11",""
"20",""
"11132","0x6456"
I would like to create a file like this:
4,23a3
5,4234
11,999999
20,999999
11132,6456
I've tried:
cat INPUT.txt | sed -e 's/0x//' -e 's/""/999999/' -e 's/"//' >> OUTPUT.txt
but I've obtained this:
4","23a3"
5","4234"
11",999999
20",999999
11132","6456"
there are two problems:
why
-e 's/"//'
can not delete all
"
?
why script create an empty line at the end of the OUTPUT.txt file ?
Thank a million
sed -e 's/0x//' -e 's/""/999999/' -e 's/"//g' INPUT.txt
>cat abc
"4","0x23a3"
"5","0x4234"
"11",""
"20",""
"11132","0x6456"
>sed -e 's/0x//g' -e 's/""/999999/' -e 's/\"//g' abc
4,23a3
5,4234
11,999999
20,999999
11132,6456
's/"//g'
's/\"//g'
both work... tnx
anyway I still have a new empty line at the end of my output file... do you have any idea?
kd09714:
>cat abc
"4","0x23a3"
"5","0x4234"
"11",""
"20",""
"11132","0x6456"
>sed -e 's/0x//g' -e 's/""/999999/' -e 's/\"//g' abc
4,23a3
5,4234
11,999999
20,999999
11132,6456
why do you need to escape a double quote?
and don't escape TWO double quotes?
sed -e 's/0x//g' -e 's/""/999999/' -e 's/\"//g' abc
---------- Post updated at 05:14 PM ---------- Previous update was at 05:09 PM ----------
either:
you had an empty line in the original file
you had a single double-quote in the original file AND 'sed' substituted to nothing in the 'last' expression
sed -e 's/0x//g' -e 's/""/999999/' -e 's/"//g' -e '/^ *$/d' abc
double quote is an empty field and I need to recognize it...
There is no empty line in the end of the original file and there are thousand of double quote in the original, by the way I've tried your last suggestion -e '/^ *$/d' but it seems not changing behavior. there still an empty line