如何在文件类型中递归查找文件,并在ssh中将它们复制到目录? [英] How to find files recursively by file type and copy them to a directory while in ssh?

查看:290
本文介绍了如何在文件类型中递归查找文件,并在ssh中将它们复制到目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在文件夹中找到所有 pdf 文件。它包含 pdf 文件和更多包含更多的目录。该文件夹位于我有ssh访问的远程服务器上。我使用mac终端,但我相信我连接的服务器是Centos。

I would like to find all the pdf files in a folder. It contains pdf files inside and more directories that contains more as well. The folder is located on a remote server I have ssh access to. I am using the mac terminal but I believe the server I am connecting to is Centos.

我需要找到所有的pdf,并将其复制到远程的一个目录服务器。我试过了大约10个变化没有运气。我和远程系统似乎不认识到--exec作为一个命令,虽然exec是好的,这是一个问题。

I need to find all the pdfs and copy them all to one directory on the remote server. I've tried about 10 variations with no luck. Both mine and the remote systems do not seem to recognise -exec as a command though exec is fine so thats a problem.

我不知道这里的问题是什么,但命令不会失败,它只是坐在那里,永远停止,所以我没有任何有用的错误发布。

Im not sure what the problem is here but the command does not fail it just sits there and stalls forever so I do not have any useful errors to post.

cp $(find -name "*.pdf" -type f; exec ./pdfsfolder {} \; | sed 1q)

find: ./tcs/u25: Permission denied
find: ./tcs/u68: Permission denied
-bash: /var/www/html/tcs_dev/sites/default/files/pdfsfolder: is a directory
-bash: exec: /var/www/html/tcs_dev/sites/default/files/pdfsfolder: cannot execute: Success
cp: target `./runaways_parents_guide_2013_final.pdf' is not a directory

这是我试过的最后一个,我想我可以忽略许可拒绝错误现在,但我不知道其余。

This is the last one I tried, I think I can ignore the permission denied errors for now but im not sure about the rest.

推荐答案

尝试:

find . -name "*.pdf" -type f -exec cp {} ./pdfsfolder \;

这篇关于如何在文件类型中递归查找文件,并在ssh中将它们复制到目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆