* Re: Upper case
@ 1999-10-26 13:51 Sven Wischnowsky
0 siblings, 0 replies; 6+ messages in thread
From: Sven Wischnowsky @ 1999-10-26 13:51 UTC (permalink / raw)
To: zsh-users
Andrei Zmievski wrote:
> On Mon, 25 Oct 1999, Geoff Wing wrote:
> > One way:
> > mv $i ${${(C)i}:s/Mp3/mp3/}
>
> Could someone explain this one to me, piece by piece? Obviously,
> s/Mp3/mp3 does a substitution but what is ${${(C)i}} all about?
It's quite simple, actually. In `${name}' substitutions, the `name'
may also be another substitution. The outer one will then work on the
result of the inner one (of course they can be nested as deeply as you
want). So the `${(C)i}' is a parameter substitution with a flag, the
`(C)'. Such flags not supported by other shells, so I think this is
what really irritates you. Zsh has several such flags, some are
rather baroque, but many are quite useful, see the `Parameter
Expansion' section in the docs (in the `zshexpn.1' man page if you use
the manual). Sorry, there are too many flags to explain all of them
here.
Anyway, the `${(C)i}' yields the contents of the parameter `i'
capitalized. This string is then used by the `${...:s/Mp3/mp3}' which
just replaces every `Mp3' with `mp3', of course.
Bye
Sven
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 6+ messages in thread
* Upper case
@ 1999-10-25 19:54 Mircea Damian
1999-10-25 21:50 ` Geoff Wing
0 siblings, 1 reply; 6+ messages in thread
From: Mircea Damian @ 1999-10-25 19:54 UTC (permalink / raw)
To: zsh-users
Hello,
I was wondering yesterday if there is a simple way to rename all my song
files(mp3) from
name with spaces.mp3 -> Name With Spaces.mp3
with something like:
for i in *.mp3; do
mv -v $i (UNKNOWN_PART_TO_ME)
done
I tried using sed there but with no luck. Can anyone give me a clue here?
--
Mircea Damian
E-mails: dmircea@kappa.ro, dmircea@roedu.net
WebPage: http://taz.mania.k.ro/~dmircea/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Upper case
1999-10-25 19:54 Mircea Damian
@ 1999-10-25 21:50 ` Geoff Wing
1999-10-26 7:39 ` Mircea Damian
1999-10-26 13:34 ` Andrei Zmievski
0 siblings, 2 replies; 6+ messages in thread
From: Geoff Wing @ 1999-10-25 21:50 UTC (permalink / raw)
To: zsh-users
Mircea Damian <dmircea@linux.kappa.ro> typed:
:I was wondering yesterday if there is a simple way to rename all my song
:files(mp3) from
:name with spaces.mp3 -> Name With Spaces.mp3
:
:with something like:
:for i in *.mp3; do
:mv -v $i (UNKNOWN_PART_TO_ME)
One way:
mv $i ${${(C)i}:s/Mp3/mp3/}
:done
Regards,
--
Geoff Wing : <gcw@pobox.com> Work URL: http://www.primenet.com.au/
Rxvt Stuff : <gcw@rxvt.org> Ego URL : http://pobox.com/~gcw/
Zsh Stuff : <gcw@zsh.org> Phone : (Australia) 0413 431 874
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Upper case
1999-10-25 21:50 ` Geoff Wing
@ 1999-10-26 7:39 ` Mircea Damian
1999-10-26 13:19 ` Mohamed LRHAZI
1999-10-26 13:34 ` Andrei Zmievski
1 sibling, 1 reply; 6+ messages in thread
From: Mircea Damian @ 1999-10-26 7:39 UTC (permalink / raw)
To: Geoff Wing; +Cc: zsh-users
On Mon, Oct 25, 1999 at 09:50:15PM +0000, Geoff Wing wrote:
> Mircea Damian <dmircea@linux.kappa.ro> typed:
> :I was wondering yesterday if there is a simple way to rename all my song
> :files(mp3) from
> :name with spaces.mp3 -> Name With Spaces.mp3
> :
> :with something like:
> :for i in *.mp3; do
> :mv -v $i (UNKNOWN_PART_TO_ME)
>
> One way:
> mv $i ${${(C)i}:s/Mp3/mp3/}
>
> :done
Thanks a lot! I've seen "C" in the manual but I thought it would capitalize
all letters. That was a wrong thought! Thanks again!
It is far better than the perl RE that I used:
s/(?:^|(?<=\s))(\w)(\w+)(?:$|(?=\.)|(?=\s))/uc($1).$2/ge
:-)
>
> Regards,
--
Mircea Damian
E-mails: dmircea@kappa.ro, dmircea@roedu.net
WebPage: http://taz.mania.k.ro/~dmircea/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Upper case
1999-10-26 7:39 ` Mircea Damian
@ 1999-10-26 13:19 ` Mohamed LRHAZI
0 siblings, 0 replies; 6+ messages in thread
From: Mohamed LRHAZI @ 1999-10-26 13:19 UTC (permalink / raw)
To: Mircea Damian, zsh-users
Hello all,
It shouldnt bother you, guys, to recieve some too simple questions from time to time hen? :)
I tried the solution :
for i in *.ps; do
mv $i ${${(C)i}:s/ch/chap/}
done
I had these .ps files :
evol.ch2.37p.ps evol.ch3.54p.ps evol.intro.3p.ps evol.ch1.13p.ps
my zsh command changed them to :
Evol.Evol.Ch3.54p.Ps Ch1.13p.Ps Evol.Ch2.37p.Ps Evol.Intro.3p.Ps
I am using ZSH_VERSION=3.1.2 on solaris 7.
Yes, sorry, didnt read in man page on this, just hoped to learn this one w/o any efforts :)
Thanx.
Mohamed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Upper case
1999-10-25 21:50 ` Geoff Wing
1999-10-26 7:39 ` Mircea Damian
@ 1999-10-26 13:34 ` Andrei Zmievski
1 sibling, 0 replies; 6+ messages in thread
From: Andrei Zmievski @ 1999-10-26 13:34 UTC (permalink / raw)
To: Geoff Wing; +Cc: zsh-users
On Mon, 25 Oct 1999, Geoff Wing wrote:
> One way:
> mv $i ${${(C)i}:s/Mp3/mp3/}
Could someone explain this one to me, piece by piece? Obviously,
s/Mp3/mp3 does a substitution but what is ${${(C)i}} all about?
-Andrei
* Anything will fit if you push hard enough *
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~1999-10-26 13:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-10-26 13:51 Upper case Sven Wischnowsky
-- strict thread matches above, loose matches on Subject: below --
1999-10-25 19:54 Mircea Damian
1999-10-25 21:50 ` Geoff Wing
1999-10-26 7:39 ` Mircea Damian
1999-10-26 13:19 ` Mohamed LRHAZI
1999-10-26 13:34 ` Andrei Zmievski
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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).