[Info-vax] Long uptime cut short by Hurricane Sandy
Joseph Huber
joseph.huber at NOREPLY.web.de
Fri Feb 1 04:30:23 EST 2013
Simon Clubley wrote:
> On 2013-01-31, Johnny Billquist <bqt at softjar.se> wrote:
>> On 2013-01-31 19:05, Simon Clubley wrote:
>>
>> While I agree with many things you write here, one is very different in
>> my mind.
>> Renames...
>>
>> > rename is far more powerful; you can specify a part of a filename to be
>> > replaced with another string and apply this to a set of files.
>>
>> Really? How? mv in unix has more than its fair share of brain damage. It
>> can essentially work in two modes:
>> 1 - Given two arguments and the second not being a directory, it renames
>> the first argument to the second, unless the second already exists. It
>> does not do any kind of pattern matching, replacing, or anything at all.
>> 2 - Given atleast two arguments, where the last argument is a directory,
>> it will move all the n-1 arguments into the last argument, being a
>> directory. No renaming of the files as such at all happens.
>>
>> One very obvious thing it cannot do, which is not unheard of in DCL is
>> just simply renaming a bunch of files, such as (in DCL):
>>
>> RENAME *.FOO *.BAR
>>
>> mv just cannot do this. And shell globbing will not help you either.
>> You'll have to write a loop with a rather elaborate scheme to implement
>> this rather simple thing.
>>
>> So, what are you thinking about in your comment? What have I totally
>> missed?
>>
>
> The fact I am not talking about mv at all but the rename command. :-)
>
> Read the man page for rename and then think about what you can do with it
> that you could not possibly do on VMS.
>
>> (And by the way, wildcard handling in Unix has its ups and downs. I'm
>> not overly impressed by it, but it's a workaround that sometimes is
>> useful, except of course every program have to implement this itself if
>> it wants to be able to deal with wildcards. No common library for that
>> stuff.)
Well: which Unix/Linux rename command ?
on my Suses linux at home it is
rename from to file...
rename will rename the specified files by replacing the first occurrence
of from in their name by to.
on Ubuntu at work it is
rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]
example: rename 's/\.bak$//' *.bak
I sometimes fall ovger the different syntax and functionality.
BTW: the Ubuntu rename perl script works on VMS as well !
> In many cases, letting the shell do the expansion instead of the program
> achieves the same thing and stops you from having to add wildcard
> expansion code into every program.
>
> You can always escape the wildcard if you want the program to handle the
> expansion itself.
>
> Simon.
>
--
Remove NOREPLY. from Email address.
Joseph Huber, http://www.huber-joseph.de
More information about the Info-vax
mailing list