Reputation: 99
I have a script in unix that looks like this:
#!/bin/bash
gcc -osign sign.c
./sign < /usr/share/dict/words | sort | squash > out
Whenever I try to run this script it gives me an error saying that squash is not a valid command. squash is a shell script stored in the same directory as this script and looks like this:
#!/bin/bash
awk -f squash.awk
I have execute permissions set correctly but for some reason it doesn't run. Is there something else I have to do to make it able to run like shown? I am rather new to scripting so any help would be greatly appreciated!
Upvotes: 0
Views: 114
Reputation: 5663
As mentioned in @Biffen's comment, unless .
is in your $PATH
variable, you need to specify ./squash
for the same reason you need to specify ./sign
.
When parsing a bare word on the command line, bash checks all the directories listed in $PATH
to see if said word is an executable file living inside any of them. Unless .
is in $PATH
, bash won't find squash
.
To avoid this problem, you can tell bash not to go looking for squash
by giving bash the complete path to it, namely ./squash
.
Upvotes: 2