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
?find
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"ls -1R
.grep
. See my answer.-1R
switch. Apparently the results are the same.