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.

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

1 Answer 1

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.

1
  • 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
    Commented Feb 28, 2018 at 3:25

Not the answer you're looking for? Browse other questions tagged .