smilidon
asked on
Change chars(hex) in files with a script
Hi,
can anyone help me to write a script? I want to change all chars in a file with the hex "DC" to "9A".
Thanks a lot.
can anyone help me to write a script? I want to change all chars in a file with the hex "DC" to "9A".
Thanks a lot.
Oops, you did say hex characters. It should then actually be:
sed -e 's/\xDC/\x9A/g' myfile > mychangedfile
sed -e 's/\xDC/\x9A/g' myfile > mychangedfile
jdfox, which sed implementation are you using where that works? I've tried it with GNU sed and Solaris 8 sed, and neither of them did what was expected.
smilidon, I believe this should work for you:
nawk '{gsub("\xDC", "\x9A"); print}' file
If you don't have 'nawk' then try gawk/mawk/awk or whatever you have, as long as it supports the gsub() function.
smilidon, I believe this should work for you:
nawk '{gsub("\xDC", "\x9A"); print}' file
If you don't have 'nawk' then try gawk/mawk/awk or whatever you have, as long as it supports the gsub() function.
ASKER
Hi, thanks for your help. it dont work jdfox. the hex chars are the same as before.
jimbb:
i try:
# nawk '{gsub("\xDC", "\x9A"); print}'yjvoll.htx
Syntax Error The source line is 1.
The error context is
{gsub("\xDC", "\x9A"); >>> print}yjvoll. <<< htx
awk: 0602-500 Quitting The source line is 1.
and get this error message. Can you help please?
Thanks
jimbb:
i try:
# nawk '{gsub("\xDC", "\x9A"); print}'yjvoll.htx
Syntax Error The source line is 1.
The error context is
{gsub("\xDC", "\x9A"); >>> print}yjvoll. <<< htx
awk: 0602-500 Quitting The source line is 1.
and get this error message. Can you help please?
Thanks
ASKER
Hi, thanks for your help. it dont work jdfox. the hex chars are the same as before.
jimbb:
i try:
# nawk '{gsub("\xDC", "\x9A"); print}'yjvoll.htx
Syntax Error The source line is 1.
The error context is
{gsub("\xDC", "\x9A"); >>> print}yjvoll. <<< htx
awk: 0602-500 Quitting The source line is 1.
and get this error message. Can you help please?
Thanks
jimbb:
i try:
# nawk '{gsub("\xDC", "\x9A"); print}'yjvoll.htx
Syntax Error The source line is 1.
The error context is
{gsub("\xDC", "\x9A"); >>> print}yjvoll. <<< htx
awk: 0602-500 Quitting The source line is 1.
and get this error message. Can you help please?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sed -e 's/DC/9A/g' myfile > mychangedfile