But if you want to be absolutely sure, simply search through
all shell scripts in all directories in your PATH.
An easy way to do this is to use the file(1) command,
which we saw in Chapter 5 and
Chapter 9.
file prints "executable
shell script" when given the name of one.
(The exact message varies from system to system;
make sure that yours prints this message when given the
name of a shell script. If not, just substitute the message
your file command prints
for "shell script" in the following example.)
Here is a script that looks for ^ in shell scripts
in every directory in your PATH:[137]
dirs=$(print -- $PATH |
sed -e 's/^:/.:/' -e 's/::/:.:/' -e s'/:$/:./' -e 's/:/ /g')
for d in $dirs
do
print "checking $d:"
cd "$d"
scripts=$(file * | grep 'shell script' | cut -d: -f1)
grep -l '\^' $scripts /dev/null
done
The first statement of this script pulls $PATH
apart into separate directories, including handling the
several cases of empty separators which signify the current
directory. The sed(1) program is a
stream editor that performs editing operations on its
input, and prints the changed contents on its output.
The result is assigned to dirs, which
is then used as the
item list in the for loop.
For each directory, it cds there
and finds all shell scripts by piping the file
command into grep and then, to extract the filename
only, into cut.
Then it searches each script for the ^ character.
The -l option to grep
simply lists all filenames that match the pattern, without printing
the matching lines.
The grep command has /dev/null
on the end of the list of files in case $scripts
happens to be empty.
If you're adventurous, you could do all the work on one line:
grep -l '\^' $(file * | grep 'shell script' | cut -d: -f1) /dev/null