列出linux中包含*.pdf文件的所有目录,并将结果通过管道传输到文件
Linux中有没有一种方法可以使用grep之类的工具列出包含*.pdf文件的所有目录,并将所有结果传送到一个文件中 我之所以要这样做,是因为我有一个基于html的大型静态网站,我想列出所有包含pdf的URL 站点结构是一种典型的树结构,具有许多级别和子级别,这是一个小的简化示例:列出linux中包含*.pdf文件的所有目录,并将结果通过管道传输到文件,linux,grep,Linux,Grep,Linux中有没有一种方法可以使用grep之类的工具列出包含*.pdf文件的所有目录,并将所有结果传送到一个文件中 我之所以要这样做,是因为我有一个基于html的大型静态网站,我想列出所有包含pdf的URL 站点结构是一种典型的树结构,具有许多级别和子级别,这是一个小的简化示例: public_html/ content/ help/ advice/ marketing/ campaign1/
public_html/
content/
help/
advice/
marketing/
campaign1/
pdfs/
campaign2/
pdfs/
shop/
templates/
nav/
guarantees/
includes/
etc...
我想搜索这个结构,并列出其中包含的所有PDF,然后将它们导入到一个文件中。示例输出如下所示,每一个新结果位于一个新行上:
public_html/content/marketing/campaign1/pdfs/example1.pdf
public_html/content/marketing/campaign1/pfds/example2.pdf
public_html/shop/templates/nav/guarantees/guarantee.pdf
我只想要公共html文件夹中的PDF。我不想搜索我的家,bin,tmp,var等等。。。硬盘上的文件夹 您可以通过find命令执行此操作
find /public_html -mindepth 1 -iname "*.pdf" -type f > output-file
说明:
/public_html # Directory on which the find operation is going to takesplace.
-mindepth 1 # If mindepth is set to 1, it will search inside subdirectories also.
-iname "*.pdf" # Name must end with .pdf.
-type f # Only files.
您可以通过find命令执行此操作
find /public_html -mindepth 1 -iname "*.pdf" -type f > output-file
说明:
/public_html # Directory on which the find operation is going to takesplace.
-mindepth 1 # If mindepth is set to 1, it will search inside subdirectories also.
-iname "*.pdf" # Name must end with .pdf.
-type f # Only files.
希望这能有所帮助
查找“目录”| grep.pdf>outputfile
示例:查找桌面/| grep pdf>1.txt希望这会有所帮助
查找“目录”| grep.pdf>outputfile
示例:查找桌面/| grep pdf>1.txt