Reputation: 3507
Here's a MWE:
#!/bin/bash
INFILE=$1
echo `echo $INFILE | awk '{print(substr($0,8,3))}'`
PATH=${INFILE%/*}
echo `echo $INFILE | awk '{print(substr($0,8,3))}'`
exit
Apparently the first awk
command runs fine, but in the second command bash
doesn't recognize awk
anymore!
This is what I get running it (assuming that f_mwe.sh
is the name of the file):
$ ./f_mwe.sh /home/something/path/this_is_the_name.txt
ome
./f_mwe.sh: line 31: awk: command not found
$
I have tried defining /bin/sh
and ksh
at the beginning also but got the same results. I have no idea what's causing this.
Any help is appreciated.
Upvotes: 1
Views: 297
Reputation: 21620
You are overwriting the PATH variable and not appending to it I believe. You should append to the PATH variable.
Upvotes: 4