I am in a directory which contains more directories.
What command can I use to get all files ending with .rb?
Asked
Active
Viewed 7.2k times
43
Martin Thoma
- 108,021
- 142
- 552
- 849
balaji
- 913
- 2
- 11
- 24
-
3For future reference, these types of questions belong here: http://unix.stackexchange.com/ – jonescb Mar 21 '11 at 15:15
5 Answers
14
Try this find . -type f -name '*.rb'.
For a more thorough explanation, get the 'Unix Power Tools' book.
Victor Sorokin
- 11,695
- 1
- 33
- 49
-
2wouldn't that also find files without a dot in front of the `rb`? The OP was very specific, so I think your answer should be too :) – 0xC0000022L Mar 21 '11 at 13:17
5
This should help:
find . | grep *\.rb
pechenie
- 1,868
- 1
- 18
- 17
-
Sorry, overlooked. Reverted. I was taken aback by using 'pipe grep' in case when all needed functionality already built-in inside `find`. – Victor Sorokin Mar 21 '11 at 11:49
-
1
0
You can find all the files ending with .rb by following command
find . -type f -name '*.rb'
To store the results after finding, you can use the following command
filesEndingWithRb=$(find . -type f -name '*.rb')
To print the results
echo $filesEndingWithRb
Akshay Chopra
- 659
- 8
- 10