📄 bin-grep.sh
字号:
#!/bin/bash# bin-grep.sh: Locates matching strings in a binary file.# A "grep" replacement for binary files.# Similar effect to "grep -a"E_BADARGS=65E_NOFILE=66if [ $# -ne 2 ]then echo "Usage: `basename $0` search_string filename" exit $E_BADARGSfiif [ ! -f "$2" ]then echo "File \"$2\" does not exist." exit $E_NOFILEfi IFS=$'\012' # Per suggestion of Anton Filippov. # was: IFS="\n"for word in $( strings "$2" | grep "$1" )# The "strings" command lists strings in binary files.# Output then piped to "grep", which tests for desired string.do echo $worddone# As S.C. points out, lines 23 - 30 could be replaced with the simpler# strings "$2" | grep "$1" | tr -s "$IFS" '[\n*]'# Try something like "./bin-grep.sh mem /bin/ls"#+ to exercise this script.exit 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -