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
  • 713,503
  • 59
  • 514
  • 593
user3742475
  • 7
  • 1
  • 1
  • 5

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
  • 57,407
  • 13
  • 129
  • 202