From: Glynn Clements <glynn@gclements.plus.com>
To: Jeff Woods <Kazrak+kernel@cesmail.net>
Cc: zyserman@fcaglp.unlp.edu.ar, linux-admin@vger.kernel.org
Subject: Re: renaming multiple files
Date: Fri, 10 Dec 2004 15:17:44 +0000 [thread overview]
Message-ID: <16825.48664.813548.45533@cerise.gclements.plus.com> (raw)
In-Reply-To: <6.1.2.0.0.20041209135423.0341cb68@mail.speakeasy.net>
Jeff Woods wrote:
> At 12/9/2004 07:09 PM +0000, Glynn Clements wrote:
> >Jeff Woods wrote:
> >>> for file in prefix-* ; do
> >>> mv "$file" "${file##prefix-}"
> >>> done
>
> >>What happens if one of the files is named "prefix-prefix-1"?
> >
> >It gets renamed to prefix-1, which is what I would expect.
>
> No. Because you used two of "##" it removes all instances of "prefix1"
> from the front of the variable and the resulting filename would be "1".
Not here:
$ file=prefix-prefix-1
$ echo "${file##prefix-}"
prefix-1
AFAICT, the difference between # and ## (shortest/longest match) is
only relevant if the pattern contains wildcards, not for fixed
strings.
> >>What about "prefix-"?
> >>
> >>I suggest:
> >>
> >>for file in prefix-?*
> >>do
> >>mv "$file" "${file#prefix-}"
> >>done
> >
> >Huh?
>
> I added "?" to the pattern so that a file with the exact name "prefix-"
> would not be selected since that would result in a modified filename that
> was an empty string.
OK.
--
Glynn Clements <glynn@gclements.plus.com>
prev parent reply other threads:[~2004-12-10 15:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-22 15:57 renaming multiple files Fabio Zyserman
2004-11-22 16:42 ` harry_b
2004-11-22 18:03 ` urgrue
[not found] ` <2005107FDBE38F10D101E700@192.168.1.247>
2004-11-22 18:30 ` Helge Pettersen
2004-11-23 1:30 ` Glynn Clements
2004-12-08 1:05 ` Jeff Woods
2004-12-09 19:09 ` Glynn Clements
2004-12-09 21:02 ` Jeff Woods
2004-12-10 15:17 ` Glynn Clements [this message]
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=16825.48664.813548.45533@cerise.gclements.plus.com \
--to=glynn@gclements.plus.com \
--cc=Kazrak+kernel@cesmail.net \
--cc=linux-admin@vger.kernel.org \
--cc=zyserman@fcaglp.unlp.edu.ar \
/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).