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.
smilidonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jdfoxCommented:
Try this:

sed -e 's/DC/9A/g' myfile > mychangedfile

0
jdfoxCommented:
Oops, you did say hex characters.  It should then actually be:

sed -e 's/\xDC/\x9A/g' myfile > mychangedfile

0
jimbbCommented:
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.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

smilidonAuthor Commented:
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
0
smilidonAuthor Commented:
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
0
jimbbCommented:
You are missing the space between the end of the script, and your input filename.

print}'yjvoll.htx
should be
print}' yjvoll.htx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.