in reply to Re: How to replace spaces with different chars?
in thread How to replace spaces with different chars?

I had the same idea, it's far more efficient!

But you still need a second step where you only grep those files matching [;:,-] at the missing spots, otherwise you will have false positives like fidlee

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^3: How to replace spaces with different chars?
by kcott (Archbishop) on Jul 07, 2022 at 13:12 UTC

    ++ Well spotted.

    If I add fidlee:

    $ ls -1 a/b/c/d/e 'f:i-:l;e' 'fi:l;e' 'f-i:l;e' 'f-i-:l;e' fi:le fidlee

    I get an additional line in the output:

    *** Files matching 'a/b/c/d/e/fi l e': 'a/b/c/d/e/fi:l;e' a/b/c/d/e/fidlee

    Changing y/ /?/ to s/ /[\\;:,-]/g fixes this. I've updated my post.

    — Ken

        does ls really support regex-character classes?

        It isn't ls which supports it, but the shell's globbing. All shell globs support character classes inside square brackets. Well, all Bourne-like shells anyway.


        🦛

        I see ++hippo has provided an answer.

        For full documentation of what's happening, see man bash; follow the EXPANSION link; scroll down (lots) to "Pathname Expansion" for screenfuls of information.

        — Ken