home/andhra1/node1/*.txt
ファイルhome/andhra1/noden/*.txt
とhome/andhra2/node1/*.txt
他のサブディレクトリ内のすべてのファイルを1つのディレクトリにコピーする必要があります。
以下は私が書いたシェルスクリプトです。
fromPath='source path'
echo $fromPath
file='destination path/*.pdf'
echo $file
toPath='destination path'
echo $toPath
for i in $file;
do
filePath=$i
if [ -e $filePath ];
then
echo $filePath
yes | cp -rf $filePath $toPath
else
echo 'no files'
fi
done
ベストアンサー1
次のコードを試してください。
find /home/andhra1 -maxdepth 3 -name "*.txt" -type f -exec mv '{}'
destinationPath/ \;