0

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!

1
  • 7
    squash./squash Commented Apr 17, 2015 at 19:30

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.