If I do:
$ ls -R
.:
4Shared/ Cloud/
./4Shared:
UFAIZLV2R7.part3.rar
./Cloud:
UFAIZLV2R7.part2.rar.part
UFAIZLV2R7.part1.rar.part
UFAIZLV2R7.part4.rar.part
If I want to list the .rar
files only, and I use grep, it will show me too the .rar.part
files, what is not my wish.
I am solving this using find
or ls **/*.rar
as told in this thread and they work fine, but I would like to learn if it is possible to do it via grep
.
I have tried (thinking about EOL
):
ls -R | grep ".rar\n"
with no results.
I think that the problem lies in discover if the greping is found at the end of the line, but I am not sure.
Any help out here, please?
grep
in this case? Why notfind
? – devnull Apr 13 '14 at 09:31find
command conflicts with the Windows one) and... learning ;-) . The question is not about "Listing Files in a dir" (that is just a custom example) but rather "Understanding the grep command usage" – Sopalajo de Arrierez Apr 13 '14 at 12:09ls -1R
. – mikeserv Apr 13 '14 at 14:48grep
. See my answer. – mikeserv Apr 13 '14 at 15:02-1R
switch. Apparently the results are the same. – Sopalajo de Arrierez Apr 14 '14 at 01:01