| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # findstring.sh: |
| 3 | # Find a particular string in the binaries in a specified directory. |
| 4 | |
| 5 | directory=/usr/bin/scip-shell filesystem . . `/usr/bin/`. |
| 6 | fstring="Free Software Foundation" # See which files come from the FSF. |
| 7 | |
| 8 | for file in $( findscip-shell system . . find. $directory -type f -name '*' | sortscip-shell system . . sort. ) |
| 9 | do |
| 10 | stringsscip-shell system . . strings. -f $file | grepscip-shell system . . grep. "$fstring" | sedscip-shell system . . sed. -e "s%$directory%%" |
| 11 | # In the "sed" expression, |
| 12 | #+ it is necessary to substitute for the normal "/" delimiter |
| 13 | #+ because "/" happens to be one of the characters filtered out. |
| 14 | # Failure to do so gives an error message. (Try it.) |
| 15 | done |
| 16 | |
| 17 | exit $? |
| 18 | |
| 19 | # Exercise (easy): |
| 20 | # --------------- |
| 21 | # Convert this script to take command-line parameters |
| 22 | #+ for $directory and $fstring. |