モバイルファイルシェル

モバイルファイルシェル

こんにちは、シェルプログラム(.sh)に問題があります。このコードを使用して、sorbenteディレクトリからターゲットディレクトリにJPGファイルをコピーする必要がありますが、コードは機能しません。助けてもらえますか?

#!/bin/bash

sorgente=$1
destinazione=$2


cd sorgente

for i in *.jpg
do

  #controllo che la directory sia leggibile
   if test -r $i 
   then

     #controllo che il file $i non sia presente nella destinazione
       if test -r $2 
         then 
            #in questo caso è presente nella destinazione
          mv $i "$destinazione/duplicati"  

         else
            mv $i "$destinazione"
       fi

  else
       echo "il file $i non è leggibile da questo utente"

   fi

done

ベストアンサー1

このコードで問題を解決しました。

sorgente=$1
destinazione=$2

echo "\n Sorgente:  $sorgente \n" 
echo "\n Destinazione:  $destinazione \n"


cd "$sorgente"

for i in *.JPG
do

  #controllo che la directory sia leggibile
   if test -r "$i" 
   then

     #controllo che il file $i non sia presente nella destinazione
       if test -r "$2" 
         then 
            #in questo caso è presente nella destinazione
            # mv "$i" "$destinazione/duplicati"  

           # else
            mv "$i" "$destinazione"
       fi

  else
       echo "il file $i non è leggibile da questo utente"

   fi

done

おすすめ記事