On 12 December 2011 15:41, Ethan Dicks <ethan.dicks at gmail.com> wrote:
On Mon, Dec 12, 2011 at 8:06 AM, Liam Proven
<lproven at gmail.com> wrote:
On 12 December 2011 03:27, Ethan Dicks
<ethan.dicks at gmail.com> wrote:
On Sat, Dec 10, 2011 at 11:59 AM, Liam Proven
<lproven at gmail.com> wrote:
For instance, I frequently need to do things
like:
REN *.log *.old
... which works fine on DOS, Windows and most other OSs but doesn't
work on Unix/Linux.
On RedHat, this should work...
rename .log .old *.log
Would that not look for 2 files, called dot-log and dot-old?
Nope. ?The binary 'rename' command (not the Perl script) ?takes N
args, the first is what string to look for in a filename, the second
string is what to replace it with, and 3-N are filenames to change
(including a list generated by the shell expanding a wildcard). ?It's
not recursive, so if you wanted to change multiple occurrences of the
search string, you'd have to run the command multiple times. ?This
wouldn't affect your example of changing a dot and a three-letter
extension.
The manpage summary lists the command as "rename from to file", if
that helps. ?In general, because of wildcard expansion by the shell,
UNIX commands (like "grep" to use a more common example) put fixed
args first and filenames last. ?You can know, in the case of grep,
that you have one string argument for a regular expression to search
for, then a random-length list of files to search for it in. ?For
'rename', it's two fixed arguments and a random-length list of
filenames to apply those arguments to.
I had thought that 'rename' was only a RedHat/CentOS command, and in a
literal sense, it is. ?Under Debian-flavored distros, it's called
'rename.ul' (presumably to avoid conflicting with the "other" rename).
?It's part of the util-linux package so it's optional and may or may
not be on a given box depending on what packages you've installed.
ftp://ftp.kernel.org/pub/linux/utils/util-linux/
Blimey. Well, TFTI, as they say - I shall investigate!
I'm not going to attempt to claim UNIX (and by way
of inheritance,
Linux) isn't confusing, but I ran across it when my experience up to
that time was largely on the Commodore PET, C-64, and VAX/VMS. ?I had
the same steep "learning cliff" as everyone else, but perhaps since I
started off as a programmer, I'm more of the target audience for it
than some.
[Nod]
It's one of those things. I admire it, I love what Linux has achieved
and it's my chosen day-to-day productivity OS as well as that which I
work with.
OTOH, I still don't grok it and I think I never will. It's nearly
2012. I want a computer that reads my mind, not one whose language I
have to speak.
--
Liam Proven ? Info & profile:
http://www.google.com/profiles/lproven
Email: lproven at cix.co.uk ? GMail/GoogleTalk/Orkut: lproven at
gmail.com
Tel: +44 20-8685-0498 ? Cell: +44 7939-087884 ? Fax: + 44 870-9151419
AIM/Yahoo/Skype: liamproven ? MSN: lproven at
hotmail.com ? ICQ: 73187508