This question already has an answer here:
I can run this from the command line and it works:
find /var/www/vhosts/foo/httpdocs/content/templates/ -name '*.plg' -print | xargs sed -i 's|mysql_|mysqli_|g'
So I wrote the following sed.sh file and call it like this: sed.sh foo
#!/bin/bash THEPATH=$1 THESTART="find /var/www/vhosts/" THEEND="/httpdocs/content/templates/ -name '*.plg' -print | xargs sed -i 's|mysql_|mysqli_|g'" if [ -z "$THEPATH" ]; then echo "You must supply a path." exit 1 fi THESEND="$THESTART$THEPATH$THEEND" echo $THESEND $THESEND
and i get the error: find: paths must precede expression: |
Why does it behave differently when run from a shell script?