dimanche 10 septembre 2017

shell script if condition too many arguments

/root/mp3/ path contains below file. i want to move the file contain letter "in" to other folder

  2017-02-10-12-11-05-in.talaw
  2017-02-10-12-11-05-out.talaw
  2017-02-10-12-12-05-in.alaw
  2017-02-10-12-12-05-out.alaw


  $FILES=/root/mp3/*
  for f in "$FILES"
  do
   ef=$(ls $f | awk -F"." '{print $1}' | awk -F "-" '{print $NF}')
  #to check in for a file
   if [ $ef = "in" ]
  #if file contian "in" letter then move to other folder )
    then 
    mv /FILES /sotrage 
    fi
  done

getting error too many arguments at if [ $ef = "in" ] if i tried with if [ "$ef" == "in" ] i am not getting current output

  i am using if [ $ef = "in" ]  to compare if file contains "in"

then only it should move files conatians in to other folder

Aucun commentaire:

Enregistrer un commentaire