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
Post a Comment