43

I am in a directory which contains more directories. What command can I use to get all files ending with .rb?

Martin Thoma
  • 108,021
  • 142
  • 552
  • 849
balaji
  • 913
  • 2
  • 11
  • 24

5 Answers5

79

You could try

find . -type f -name \*.rb
Emmanuel
  • 18,093
  • 6
  • 44
  • 73
bmk
  • 13,519
  • 5
  • 36
  • 45
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
  • 2
    wouldn'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
1

This should do it

find . -name "*t^" -print
vickirk
  • 3,847
  • 2
  • 21
  • 37
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