regex - sed: find and replace a string (with characters like $ and space) in a binary file -


i have file, there string tail +390 $0 > $outname. need find line , replace tail -n +390 $0 > $outname. trying sed --

sed -i -e 's/tail +390 \$0 > \$outname/tail -n +390 \$ > \$outname' file.bin ; 

and

sed -i -e 's/tail\ +390\ \$0\ >\ \$outname/tail\ -n\ +390\ \$\ > \$outname' file.bin ; 

the file trying modify binary file.

but can not work, hint appreciated.

you need add / @ last because sed syntax incorrect. it's s/search/replace should s/search/replace/optional-modifiers .

sed -i 's/tail +390 \$0 > \$outname/tail -n +390 \$0 > \$outname/' file 

example:

$ echo 'tail +390 $0 > $outname' | sed 's/tail +390 \$0 > \$outname/tail -n +390 \$0 > \$outname/' tail -n +390 $0 > $outname 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -