| From: Ron / BCLUG via talk <[email protected]>

| How does `rename` (a Perl program, I believe?) handle globbing and pathname
| expansion?
| 
| 
| i.e. in a folder with 3 files: one.sh, two.sh, file.tar, typing:
| 
| rename *.sh *
| 
| means rename gets passed these parameters:
| 
| one.sh two.sh one.sh two.sh file.tar

The DOS ren command is very simple.
So too is the Unix Utilities one included in Fedora by default.

        rename [options] expression replacement file...

The expression and replacement are simple strings, not patterns.
There are options like --all and --last that affect where the expression 
can be matched.

What you want is
        rename .sh '' *.sh
which means
        for each filename matched by *.sh
        change every occurrence of ".sh" in its name
        to '' (empty)

I think that regular expressions in at least "expression" would be nice.
I'd often use ^ or $, to prevent surprises.
So the perl-based version might be more useful.

But I so rarely use rename that I have to read the man page each time.
Once or twice a year.
---
Post to this mailing list [email protected]
Unsubscribe from this mailing list https://gtalug.org/mailman/listinfo/talk

Reply via email to