0

i'm writing a script but get the error : Syntax error: word unexpected (expecting "in") I don't really see where the error could be

#!/bin/bash
for dir in "$@"

do

mv "$dir"/* /tmp

done

if [ $# -lt 1 ] ; then

echo "ERROR: no argument"

exit 1  # pas 0

else

   case $#

   -d) mv -R $dir/* /tmp        
       ;;

-x) find -executable -type f | xargs mv -t "$dir"/* /tmp

;;

esac

fi
anubhava
  • 761,203
  • 64
  • 569
  • 643
user3742475
  • 7
  • 1
  • 2
  • 6

1 Answers1

4

As the error says, "in" is missing. Per the case syntax,

case word in [ [(] pattern [| pattern]…) command-list ;;]… esac

but there is no "in" after the word ($#) in the code - add it.

user2864740
  • 60,010
  • 15
  • 145
  • 220