I have some files in the filesystem that end with a trailing slash like so:

my_text_file_1.txt\
some_other_file_2.pl\

I usually use find for these cases, but the following did not work:

find . -name "*\\"

Anybody have any ideas? Thanks

link|improve this question
feedback

1 Answer

up vote 5 down vote accepted

You can double-escape it or use single quotes:

find . -name "*\\\\" -print
find . -name '*\\' -print
link|improve this answer
Nice. Exactly what i need. While I wait 9 mins to accept your answer... can you explain why i need to double escape? – superspace Apr 27 '11 at 7:09
2  
@superspace: It's the difference between single and double quotes in bash (and I think any other shell). In double quoted strings, it will still expand meta characters, so it would have first turned \` into ` as you expect. However that is then passed to find as "*\", where find expands it again. \" is a literal " character, leaving find looking for files matching "*". Double-escaping gets around that the fun way; and using single quotes tells the shell to pass everything on to the command unchanged. – SmallClanger Apr 27 '11 at 8:37
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.