I have this code to translate a word from/to English/Spanish:
S=`/usr/local/bin/trans -b -id -no-ansi "$a" | grep Code | awk '{print $2}'`
if [ "$S" = "en" ]; then T=es; else T=en; fi
/usr/local/bin/trans -b :"$T" "$a"
(trans
is from https://github.com/soimort/translate-shell/)
Running the script straight in Terminal (bash) works great.
But when I try to use it in Automator, I get this error:
/usr/local/bin/trans: line 5073: gawk: command not found
Running gawk
in Terminal also works fine.
UPDATE: Thanks to solver below, final working script for automator is:
PATH=$PATH:/usr/local/bin
S=`/usr/local/bin/trans -b -id -no-ansi "$@" | grep Code | awk '{print $2}'`
if [ "$S" = "en" ]; then T=es; else T=en; fi
/usr/local/bin/trans -b :"$T" "$@"
grep
is easy to fix; replacegrep x | awk '{y}'
withawk '/x/ {y}'