如何在 Linux 中递归地找到目录中的所有 *.js 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6355539/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 04:32:20  来源:igfitidea点击:

How can I find all *.js file in directory recursively in Linux?

linuxfind

提问by Dmitry Belaventsev

In Linux, how can I find all *.jsfiles in a directory recursively? The output should be an absolute path (like /pub/home/user1/folder/jses/file.js)

在 Linux 中,如何*.js递归查找目录中的所有文件?输出应该是绝对路径(如/pub/home/user1/folder/jses/file.js

this answer worked for me:

这个答案对我有用:

find $PWD -name '*.js' > out.txt

It finds all *.js files, output absolute path, writes the results into out.txt.

查找所有*.js文件,输出绝对路径,将结果写入out.txt。

采纳答案by e.dan

find /abs/path/ -name '*.js'

find /abs/path/ -name '*.js'

Edit:As Brian points out, add -type fif you want only plain files, and not directories, links, etc.

编辑:正如 Brian 所指出的,-type f如果您只需要纯文件,而不需要目录、链接等,请添加。

回答by Sjoerd

Use findon the command line:

使用find命令行:

find /my/directory -name '*.js'

回答by ?imon Tóth

If you just want the list, then you should ask here: http://unix.stackexchange.com

如果你只想要列表,那么你应该在这里问:http: //unix.stackexchange.com

The answer is: cd / && find -name *.js

答案是: cd / && find -name *.js

If you want to implement this, you have to specify the language.

如果要实现此功能,则必须指定语言。