?
Solved

Change chars(hex) in files with a script

Posted on 2003-03-11
6
Medium Priority
?
344 Views
Last Modified: 2010-04-20
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.
0
Comment
Question by:smilidon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 5

Expert Comment

by:jdfox
ID: 8110846
Try this:

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

0
 
LVL 5

Expert Comment

by:jdfox
ID: 8110903
Oops, you did say hex characters.  It should then actually be:

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

0
 
LVL 2

Expert Comment

by:jimbb
ID: 8114460
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
WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

 

Author Comment

by:smilidon
ID: 8117686
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
 

Author Comment

by:smilidon
ID: 8117951
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
 
LVL 2

Accepted Solution

by:
jimbb earned 200 total points
ID: 8118460
You are missing the space between the end of the script, and your input filename.

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

Featured Post

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question