Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: How to replace spaces with different chars?

by LanX (Saint)
on Jul 07, 2022 at 10:45 UTC ( [id://11145323]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11145323]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-26 04:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found