I have about 2000 subfolders in one folder, in each of these folders there are .pdf
files. I need a unix command that will move all these files up one folder.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
$ cd thefolder # which contains the subfolders and where the PDFs should land
$ find . -name *.pdf | xargs -I {} cp -iv {} .
# find all files
# which end in .pdf
# recursively from
# the current folder
# |
# for each emitted line
# copy the output (captured by {}) to
# the specified path ('.' is the current directory)
# copy should be verbose and should ask,
# in case a file would be overwritten
This should copy your files into /thefolder/
. If you want to move them replace cp
with mv
.