How does -b option in sed program perform usefully
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How does -b option in sed program perform usefully
How is the usage of -b option in sed, stream editor utility. I've been trying to find & replace a unicode text inside binary data. Which are sed's options and its command line would be to perform correct result.
For example the text 'collon' is among the binary, i.e invisible characters, and would be replaced with 'period'. So hex illustration looks like:
0 1 2 3 4 5 6 7 8 9 a b c d e f
I've not used bbe which is a binary file editor replacement for sed. Usually when I manipulate binary files, I write a program to do so.
Either case, sed does do binary format, and I'm unsure, but there are also awk and tr commands which likely will do the same.
The issue is how to represent the binary characters, using printable ASCII, because you have to type something using escape clauses to identify the binary, or hex sequences you intend to find, edit, and replace. I believe the notation is \x prior to the number.
Have you managed to write any starting commands to find the sequence or sequences you are looking to identify for changes?
Looking at the man page, I don't think -b does what you think
Code:
-b
--binary
This option is available on every platform, but is only effective where
the operating system makes a distinction between text files and binary
files. When such a distinction is made—as is the case for MS-DOS, Windows,
Cygwin—text files are composed of lines separated by a carriage return and
a line feed character, and sed does not see the ending CR. When this option
is specified, sed will open input files in binary mode, thus not requesting
this special processing and considering lines to end at a line feed.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.