#!/bin/bash: list all users.PASSWORD_FILE=/etc/passwdn=1for name in $(awk 'BEGIN{FS=":"}{print $1}' < "$PASSWORD_FILE" )do echo "USER #$n = $name" let "n+=1"doneexit $?
#!/bin/bash# bin-grep.sh: locates matching strings in a binary file.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 exit." exit $E_NOFILEfiIFS=$'\012'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 $worddoneexit 0
posted on 2012-09-20 00:58 阅读( ...) 评论( ...)