Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ディレクトリのファイルを別のディレクトリに移動する必要があります。次のプログラムを使用すると、stat エラーが発生します。
for i in dir1/*.txt_dir; do mv $i/*.txt dir2/`basename $i`.txt done
エラーメッセージ
mv: cannot stat `dir1/aa7.txt_dir/*.txt': No such file or directory
mv $i/*.txt dir2/`basename $i`.txt
にテキスト ファイルがない場合、これは機能しません$i/。シェルは、未展開の文字列"$i/*.txt"をmv含む生の文字列を*に渡しmvます。
$i/
"$i/*.txt"
mv
*
次のようなことを試してください:
for i in dir1/*.txt_dir; do find $i -name '*.txt' -exec mv {} dir2/`basename $i`.txt \; done