Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 5 down vote accepted

You can double-escape it or use single quotes:

find . -name "*\\\\" -print
find . -name '*\\' -print
share|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? –  denormalizer 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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