Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

find

In Linux, how can I find all *.js files in a directory recursively? The output should be an absolute path (like /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.

like image 894
Dmitry Belaventsev Avatar asked Jun 15 '11 09:06

Dmitry Belaventsev


People also ask

How do I find a specific file in Linux recursively?

Combine 'find' and 'grep' You can also use a combination of two commands in Linux – find and grep commands to recursively search subdirectories for files that match a grep pattern (provided with the argument): find . -type f -exec grep -l 'directory_name' {} ; This command makes the task very simple.

How do I list all files in a directory recursively?

Linux recursive directory listing using ls -R command. The -R option passed to the ls command to list subdirectories recursively.


3 Answers

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

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

like image 100
e.dan Avatar answered Oct 08 '22 04:10

e.dan


Use find on the command line:

find /my/directory -name '*.js'
like image 35
Sjoerd Avatar answered Oct 08 '22 03:10

Sjoerd


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

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

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

like image 26
Šimon Tóth Avatar answered Oct 08 '22 04:10

Šimon Tóth