I am try to find directories like


using the command

find . -name *\?.git

but get all directories ending in .git

What I'm doing is downloading a file from amazon s3 and in creating directory based on the lines in the file. I generate a file in excel then copy the values into notepad and finally upload the file to amazon s3.

I add the .git extensions before creating the directory. This might mean that I have a line ending problem in the downloaded file.

  • Try quoting the string e.g. "find . -name '*\?.git'" – uint128_t Jan 3 '16 at 17:12
  • Try find [path] -type d *\?.git – pun Jan 3 '16 at 17:14
  • Or enclose in singles quotes? – Xen2050 Jan 3 '16 at 17:25
  • find . -type d -name *\?.git gives me all directories including the directories with question marks. and find . -type d -name '*\?.git' gives me no result. – Hendré Jan 3 '16 at 17:46
  • 3
    If you have CR or other bad char in the file, you might create a name that ls displays as question-mark but is not in fact question-mark. Try ls -1b or ls -1b partialmatch*git (numeral one and lowercase bee) to see exactly what you have. – dave_thompson_085 Jan 4 '16 at 0:52

Use this to find all directories with a question mark in name:

find . -type d -name '*\?*'
| improve this answer | |
  • I get an empty directory listing when I try this. – Hendré Jan 3 '16 at 22:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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