2001-07-10 14:25:50 +00:00
|
|
|
#!/bin/bash
|
2002-04-01 16:04:17 +00:00
|
|
|
# findstring.sh:
|
2006-12-20 21:11:55 +00:00
|
|
|
# Find a particular string in the binaries in a specified directory.
|
2001-07-10 14:25:50 +00:00
|
|
|
|
|
|
|
directory=/usr/bin/
|
|
|
|
fstring="Free Software Foundation" # See which files come from the FSF.
|
|
|
|
|
|
|
|
for file in $( find $directory -type f -name '*' | sort )
|
|
|
|
do
|
|
|
|
strings -f $file | grep "$fstring" | sed -e "s%$directory%%"
|
2002-04-01 16:04:17 +00:00
|
|
|
# In the "sed" expression,
|
|
|
|
#+ it is necessary to substitute for the normal "/" delimiter
|
|
|
|
#+ because "/" happens to be one of the characters filtered out.
|
2008-11-23 22:43:47 +00:00
|
|
|
# Failure to do so gives an error message. (Try it.)
|
2001-07-10 14:25:50 +00:00
|
|
|
done
|
|
|
|
|
2008-11-23 22:43:47 +00:00
|
|
|
exit $?
|
2001-07-10 14:25:50 +00:00
|
|
|
|
2002-04-01 16:04:17 +00:00
|
|
|
# Exercise (easy):
|
|
|
|
# ---------------
|
2006-10-11 16:39:10 +00:00
|
|
|
# Convert this script to take command-line parameters
|
2002-04-01 16:04:17 +00:00
|
|
|
#+ for $directory and $fstring.
|