The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: "Michael Kjörling" <michael@kjorling.se>
To: tuhs@minnie.tuhs.org
Subject: Re: [TUHS] Origins of globbing
Date: Wed, 7 Oct 2020 09:45:17 +0000	[thread overview]
Message-ID: <e71b3082-ad52-4f9c-92e8-7f5eaa68bda1@localhost> (raw)
In-Reply-To: <202010070922.0979MUD2022625@freefriends.org>

On 7 Oct 2020 03:22 -0600, from arnold@skeeve.com:
>> Possibly wrongly, I judge glob by things like how simple it is, to use
>> it doing "rename *.foo to *.bar" or "find filenames with spaces in
>> them, and rename to be - separated"
> 
> I often use a 
> 
> 	find ... | sed 's/whatever/mv & other/' | sh -x
> 
> for fancy things like that. If I'm doing the same operation a lot,
> I wrap it in a script.

I like rename from https://metacpan.org/release/File-Rename for that
purpose. It takes a regular expressions (actually, Perl expression, so
could in principle be any valid Perl code) plus a set of file names,
and renames each file according to the regexp. Plus you don't need to
worry about things like quoting within the command as with the above,
and it even has -0 for when reading those extra-exotic file names from
stdin. (For one thing, I hope none of your files has a space or a
semicolon in its name with your style of rename as-is. :))

In Debian, that's https://packages.debian.org/stable/rename; I suspect
other systems with reasonably large package repositories also offer it
prepackaged.

About the only downside is its dependence on Perl (after all, that's
rather heavyweight), but then again a lot of other things also depend
on Perl so it's kind of hard to have even a minimal modern system that
doesn't have Perl installed...

Having to escape every '.' would probably be even more annoying than
modern GNU ls's default non-"-N" behavior; and worse in the sense that
_most_ of the time, it would probably work without escaping it, but
when it doesn't work, it would break in various spectacular fashions.

-- 
Michael Kjörling • https://michael.kjorling.se • michael@kjorling.se
 “Remember when, on the Internet, nobody cared that you were a dog?”


  reply	other threads:[~2020-10-07  9:51 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-06  9:53 Tyler Adams
2020-10-06 15:17 ` John Cowan
2020-10-07  2:25   ` Random832
2020-10-07  2:58     ` George Michaelson
2020-10-07  9:22       ` arnold
2020-10-07  9:45         ` Michael Kjörling [this message]
2020-10-08  3:45           ` John Cowan
2020-10-09 18:21             ` Random832
2020-10-08  0:18       ` Dave Horsfall
2020-10-08  0:33         ` Larry McVoy
2020-10-08  2:35         ` Dave Horsfall
2020-10-06 15:44 Noel Chiappa
2020-10-06 23:11 ` George Michaelson
2020-10-06 23:21   ` Jon Steinhart
2020-10-07  0:23     ` Warner Losh
2020-10-07  0:32       ` George Michaelson
2020-10-07  0:33         ` Jon Steinhart
2020-10-07  3:14   ` John Cowan
2021-02-04 21:29     ` Greg A. Woods

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e71b3082-ad52-4f9c-92e8-7f5eaa68bda1@localhost \
    --to=michael@kjorling.se \
    --cc=tuhs@minnie.tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).