Solved

Some thing to replace sed

Posted on 2001-07-16
7
379 Views
Last Modified: 2013-12-27
I have a file that has ascii and binary data (its actually a postscript file). I need to translate some of the string values at the beginning of the job.

I thought it would be easy

sed -e 's/123456/789012/' < input > output

The translation works correctly but the file is a different size.
I believe this is because of the binary data and inclusion of nulls.

If i try to edit the file in vi, it says line too long.

The file will edit successfully with dtpad.

Is there a version of sed that will handle the binary data and nulls or is there some other utility


 
0
Comment
Question by:markhardisty
[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
7 Comments
 
LVL 3

Expert Comment

by:interiot
ID: 6286043
vim (Vi Improved) has support for longer lines, as well as binary editing.  See http://www.vim.org/html/editing.html#edit-binary

0
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 6287679
If the file contains binary data, then it's not PostScript.  Maybe it's PDF or Encapsulated PostScript.
0
 
LVL 4

Expert Comment

by:Otetelisanu
ID: 6288648
look for sed with od -cx file
and after
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
shanechambers earned 100 total points
ID: 6289667
Perl might work better;
This will change 'file' inplace, while creating a 'file.orig' of the backup;

perl -p -i.orig -e's/123456/789012/' file
(drop the '.orig' after the -i if you don't want a backup)

An inline version of this would be;
cat file | perl -p -i -e's/123456/789012/'

Note this time I specified no backup copy was to be kept.

Just a suggestion.
0
 
LVL 4

Expert Comment

by:Otetelisanu
ID: 6289833
1. od -cx file >file1
2. sed -e 's/123456/789012/' < file > file2
3. od -cx file2 >file3
4. diff file1 file3
0
 
LVL 4

Expert Comment

by:Otetelisanu
ID: 6289835
1. od -cx file >file1
2. sed -e 's/123456/789012/' < file > file2
3. od -cx file2 >file3
4. diff file1 file3
0
 

Author Comment

by:markhardisty
ID: 6290407
Thanks every one:

Ok re the postscript comment it is an EPSF file, in fact a DCS master file with a binary preview

Vim seems a good option (took ages to download and then needed lots of extra librarys in place,) but it will edit the file, i havent had a chance to run it inline from a script though.

Im not sure i understand how the od example fixes the problem. Will try it a few more times to see if i can work it out

but the neatest and simplest is the perl solution so that gets the vote..

Thanks again.. This has dug me out of a mess
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

623 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