如何将文件移动到今天在Shell中创建的另一个目录?

时间:2016-02-29 14:45:48

标签: shell

我有以下脚本

find . -mtime 0 -type f -exec ls -ltr {} \; | grep "$(date +%d|sed 's,^0,,g') ..:.." | while read fname; do
   echo "$fname"
done

我可以打印文件细节。如何将test1.txt test2.txt文件移动到另一个目录?

输出:

[nca@ldc039 failure]$ . ../../scripts/retryFailedFiles.sh 
-rwxrwxr-x. 1 nca nca 0 Feb 29 16:16 ./test1.txt
-rwxrwxr-x. 1 nca nca 0 Feb 29 16:16 ./test2.txt 

1 个答案:

答案 0 :(得分:1)

# You can use the option -1tr instead -ltr :
find . -mtime 0 -type f -exec ls -1tr {} \; | while read fname; do
echo "$fname" 
mv $fname newfolder
done

# Or, by using the following commande :
find . -mtime 0 -type f -exec mv {} newfolder \;