1

Assume I have many files names something like:

foo_192.168.1.1.sh
bar_192.168.1.1.sh
baz_192.168.1.1.sh
qux_192.168.1.1.sh

and I want to rename them all to

foo_192.168.1.100.sh
bar_192.168.1.100.sh
baz_192.168.1.100.sh
qux_192.168.1.100.sh

How would I do this best?

mv *.1.sh .100.sh does not work.

2

There are probably 1000 ways to do this. Here's the first that came to mind:

rename 's/1\.sh/100.sh/' *

rename takes a pattern as the first argument and attempts to rename the target files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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