私はちょうどbashでシェルスクリプトを学んでいる、私はgzipを使用してターゲットディレクトリからファイルを取って、別のディレクトリに送信することができるようにしたい。私はコマンドラインにディレクトリを入力します。 extは私が圧縮したい拡張子用で、ファイルは新しいzipファイルになります。 私のスクリプトは、ファイルを適切なディレクトリに入れて、希望するディレクトリに送りますが、そのようなファイルやディレクトリにはエラーがありません。これを避けるにはどうすればいいですか?Gzipそのようなファイルやディレクトリのエラーは、まだzipsファイル
現在のコード
cd $1
for ext in $*; do
for file in `ls *.$ext`; do
gzip -c $file > $2/$file.gz
done
done
と私のI/O
[email protected]:~/Desktop/60256$ bash myCompress /home/blackton/Desktop/ /home/blackton/ txt
ls: cannot access *./home/blackton/Desktop/: No such file or directory
ls: cannot access *./home/blackton/: No such file or directory
gzip: alg: No such file or directory
gzip: proj.txt: No such file or directory
*代わりにlsの 'の' *見つける-name「*。$のEXT」型F'を使用してください。$ ext' – GMichael