mirror of https://github.com/tLDP/LDP
23 lines
677 B
Bash
23 lines
677 B
Bash
#!/bin/bash
|
|
# findstring.sh:
|
|
# Find a particular string in the binaries in a specified directory.
|
|
|
|
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%%"
|
|
# In the "sed" expression,
|
|
#+ it is necessary to substitute for the normal "/" delimiter
|
|
#+ because "/" happens to be one of the characters filtered out.
|
|
# Failure to do so gives an error message. (Try it.)
|
|
done
|
|
|
|
exit $?
|
|
|
|
# Exercise (easy):
|
|
# ---------------
|
|
# Convert this script to take command-line parameters
|
|
#+ for $directory and $fstring.
|