1

I had to wipe my drive and reinstall windows, which also required reinstalling cygwin.

In my new install,

ls -l "*\'*"

returns

ls: cannot access '*\'\''*': No such file or directory

For years up until this point, ls -l *\'* would present me a list of directories and files where users had included a single quote in file or directory names.

Any tips on what I may be missing about this situation?

For example, apparently coreutils had some changes that caused files with spaces in the name to be listed as 'This File contains spaces' and a switch/variable had to be used to turn it off.

I'm wondering if some similar change in standard use was implemented regarding the single quote.

closed as off-topic by Michael Homer, roaima, G-Man, Satō Katsura, Archemar Mar 6 '18 at 10:56

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Michael Homer, roaima, G-Man, Satō Katsura, Archemar
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    What did you expect to happen/what used to happen when you did that? – Michael Homer Feb 28 '18 at 2:52
  • I've updated my question. – Ken Ingram Feb 28 '18 at 3:02
2

You cannot quote * if you expect it to act as a wildcard. Both single and double quotes escape it.

Double quotes also escape single quotes so your whole string *\'* is going to be taken literally:

$ echo "*\'*"
*\'*

You want to write your string without the double quotes as you have written later in your question:

ls -l *\'*

Another way to do this that may be better suited for you is with the find command. (which does not follow the same quoting rules as above so sorry for the confusion). With find you can search a directory structure recursively much easier for any file containing a single quote with the below command:

find . -name "*'*"

In this example . stands for the directory you are currently in but you can replace that with a path to any directory you would like to search.

  • Thanks Jesse_b. I was pretty sure when I used no quotes, the ls command was failing. Apparently it does work, so my question was somewhat irrelevant in the long run. I thought maybe something had changed in the code. – Ken Ingram Feb 28 '18 at 3:25

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