我正在尝试搜索具有特定扩展名的文件,然后将所有文件在文件夹层次结构中向上移动一层。
基本上我有类似的东西
/path/to/application/files/and/stuff/a1/nolongerneededirectory/*.*
/path/to/application/files/and/stuff/a2/nolongerneededirectory/*.*
/path/to/application/files/and/stuff/a3/nolongerneededirectory/*.*
Run Code Online (Sandbox Code Playgroud)
我试图像这样将它们向上移动:
/path/to/application/files/and/stuff/a1/*.*
/path/to/application/files/and/stuff/a2/*.*
/path/to/application/files/and/stuff/a3/*.*
Run Code Online (Sandbox Code Playgroud)
理想情况下,它会执行以下操作:
-bash-3.2$ find /path/to/ -name '*.txt'
output:
/path/to/directories1/test1/test1.txt
/path/to/directories2/test2/test2.txt
/path/to/directories3/test3/test3.txt
then
mv /path/to/directories1/test1/test1.txt /path/to/directories1/test1.txt
mv /path/to/directories2/test2/test2.txt /path/to/directories2/test2.txt
mv /path/to/directories3/test3/test3.txt /path/to/directories3/test3.txt
Run Code Online (Sandbox Code Playgroud)
我一直在玩不同的选择并四处打听,有人有什么想法吗?
编辑 1:
所以我试过了
`find /path/to/parent/dir -type f -exec mv {} .. \
Run Code Online (Sandbox Code Playgroud)
但我得到一个权限被拒绝