Sponsored Content
Top Forums Shell Programming and Scripting Regex and backreference to replace in binary file Post 302869639 by Don Cragun on Wednesday 30th of October 2013 04:31:33 PM
Old 10-30-2013
Although some versions of sed may work on binary files, the standards only require sed to work on text files. A simple way that should work on most current systems is to use tr:
Code:
LC_ALL=POSIX tr '\100-\117' '\040-\057' <in_file >out_file

Some implementations of the tr utility may accept hex ranges, but the standards only specify octal as shown above. If your current locale has an underlying code set that only has single-byte eight-bit characters (such as ASCII or EBCDIC; but not UTF-8), you can skip the LC_ALL=POSIX.

Note, however, that if your image includes geolocation, timestamp, or camera settings data in addition to the actual image, you might not like the results unless you can extract just the image data you want to be processed.

Last edited by Don Cragun; 10-30-2013 at 05:33 PM.. Reason: fix typo
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replace string in binary file

Dear all, How can replace special string with another string in binary file? Thanks&Best Regards (2 Replies)
Discussion started by: sg1207
2 Replies

2. UNIX for Dummies Questions & Answers

replace line after a regex

Hi, I am trying to write a script which will modify a given account's settings by searching for a line in a file and then replacing the line after it. Here is a portion of my input file: type=friend username=0002 secret=password host=dynamic dtmfmode=rfc2833 mailbox=0002 context=sip... (2 Replies)
Discussion started by: the1armedcoder
2 Replies

3. Emergency UNIX and Linux Support

search replace regex question

Hi, I need to run a search and replace on a large database, what I need to change is all instances of #### (eg. 1764 or 1964) to (####) (eg. (1764) or (1964)) But there might be other numbers in there such as (1764) and I do not need those changed to ((1764)) How can I... (7 Replies)
Discussion started by: lawstudent
7 Replies

4. Shell Programming and Scripting

sed regex backreference replacement

Hello, I want to rename multiple files and catch some points about backreference within sed and regex. Here is a part of my file list. Input: S92A.fa S92B.fa ... S96Z.fa S921.fa S922.fa ... S997.fa Note: The file names are not necessarily continuous from A~Z or 921 ~ 997, as some of the... (3 Replies)
Discussion started by: yifangt
3 Replies

5. UNIX for Dummies Questions & Answers

read regex from ID file, print regex and line below from source file

I have a file of protein sequences with headers (my source file). Based on a list of IDs (which are included in some of the headers), I'd like to print out only the specified sequences, with only the ID as header. In other words, I'd like to search source.txt for the terms in IDs.txt, and print... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

6. Shell Programming and Scripting

Convert binary file to csv and then back to the binary format

Hello *nix specialists, Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
Discussion started by: digidax
7 Replies

7. Shell Programming and Scripting

Regex - search and replace

I have file which contains data in the following format all in a single line: BDW_PUBLN_ID DECIMAL(18:0) NOT NULL PRIMARY INDEX ARGO_ACCT_DEP_PI ( OFC_ID ,CSHBX_ID ,TRXN_SEQ_NUM ,PROCG_DT ) PARTITION BY RANGE_N(PROCG_DT BETWEEN DATE '2012-03-01' AND DATE '2014-12-31' EACH INTERVAL '1' MONTH );... (4 Replies)
Discussion started by: ysvsr1
4 Replies

8. UNIX for Dummies Questions & Answers

Binary search and replace

Hello again. I have two problems - is it possible to solve them? 1. I want to replace a few bytes after specific hex-string. i.e.: I want to replace two bytes after AA AB AC: AA AB AC 00 00 AA AA AA so the expected result should be: AA AB AC FF FF AA AA AA 2. I want to replace three bytes... (9 Replies)
Discussion started by: useretail
9 Replies

9. UNIX for Advanced & Expert Users

Segregate file content using sed backreference

I have some text like EU1BTDAT:ASSGNDD filename='$SEQFILES/SUNIA.PJ008202.CARDLIB/DATECARD' EU1BTDATEST:ASSGNDD filename='$SEQFILES/SUNIA.PJ008202.CARDLIB/DATECARD' EU1CLOSEDATES:ASSGNDD filename='$SEQFILES/SUNIA.PJ008202.CARDLIB/DATECARD' EU1DATED:ASSGNDD... (8 Replies)
Discussion started by: gotamp
8 Replies

10. UNIX for Beginners Questions & Answers

Regex Expression Replace

I have a XML file where there is a tag with like <wd:address_line_1>1234 Street</wd:address_line_1> I want to replace the values "1234 Street" with "Test Data". Different people have different address lines and i want to replace with a fixed value to mask the file. I was trying to use sed... (7 Replies)
Discussion started by: dr46014
7 Replies
tuned.conf(5)						tuned.conf file format description					     tuned.conf(5)

NAME
tuned.conf - Tuned profile definition DESCRIPTION
This man page documents format of Tuned 2.0 profile definition files. Profile is stored in /etc/tuned/<profile_name>/tuned.conf or in /usr/lib/tuned/<profile_name>/tuned.conf file where the /etc/tuned/ directory has higher priority. The tuned.conf configures the profile and it is in ini-file format. MAIN SECTION
The main section is called "[main]" and can contain following options: include= Includes config file defined as value. Config file can be defined as full path or by the profile name to which it belongs. If this parameter is present, the histogram will be shown at the end of the measurement. PLUGINS
Every other section defines one plugin. The name of the section is used as name for the plugin and is used in logs to identify the plugin. There can be only one plugin of particular type tuning particular device. Conflicts are by default fixed by merging the options of both plugins together. This can be changed by "replace" option. Every plugin section can contain following sections: type= Plugin type. Currently there are following plugins: disk, script, net, cpu, eeepc_she. devices= Comma separated list of devices which should be tuned by this plugin instance. If you omit this option, all found devices will be tuned. replace=1 If there is conflict between two plugins (meaning two plugins of the same type are trying to configure the same devices), then the plugin defined as last replaces all options defined by the previosly defined plugin. Plugins can also have plugin related options. EXAMPLE
[main] # Includes plugins defined in "included" profile. include=included # Define my_sysctl plugin [my_sysctl] type=sysctl # This plugin will replace any sysctl plugin defined in "included" profile replace=1 # 256 KB default performs well experimentally. net.core.rmem_default = 262144 net.core.wmem_default = 262144 # Define my_script plugin # Both scripts (profile.sh from this profile and script from "included" # profile) will be run, because if there is no "replace=1" option the # default action is merge. [my_script] type=script script=profile.sh SEE ALSO
tuned(8) AUTHOR
Written by Jan Kaluza <jkaluza@redhat.com>. REPORTING BUGS
Report bugs to <jkaluza@redhat.com>. Jan Kaluza 13 Mar 2012 tuned.conf(5)
All times are GMT -4. The time now is 02:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy