Re: [Linuxcommand-discuss] Greetings & a Script
Brought to you by:
bshotts
|
From: Bruce B. <bbu...@ea...> - 2002-08-29 03:16:20
|
----- Original Message -----
From: "William Shotts" <wes...@co...>
To: <lin...@li...>
Sent: Wednesday, August 28, 2002 7:14 PM
Subject: Re: [Linuxcommand-discuss] Greetings & a Script
> On Wednesday 28 August 2002 08:36 pm, Bruce Burhans wrote:
>
> > > First, you could simplify it by doing the following:
> > >
> > > #!/bin/bash
> > >
> > > old=$1
> > > new=$2
> > >
> > > for i in *$old; do
> > > k=$(basename $i $old)
> > > mv $i $k$new
> > > done
> > >
> > > I haven't tested this, but it looks right ;-)
> >
> > Bill.....I have bad news and good news.....
> >
> > The script above puts the new extension on every file
> > in the directory, regardless of its present extension...
> > The test part is needed....
>
> Try it again Bruce. The "for" will only select files that have the old
> extension. Make sure you are using:
>
> for i in *$old;
>
> and not
>
> for i in * $old;
>
> If you include a space between the "*" and the "$old", it will process all
> the files.
Ahh! Oops! Dot thy i's and cross thy t's.....
>
> >
> > I am a good way through your scripting tutorial, and it
> > is the best one out of a half-dozen I have on my box..
> >
> > You take the time to explain what is going on, to answer
> > obvious questions that pop up, and are oriented towards
> > functionality. For example: Not one of the other tutorials
> > mentions that you bash has a help command.....
> >
> > I've read the entire bash reference manual, and had no
> > idea that such a thing existed.......Nor do any of them
> > tell you that you put a function in your .bashrc.....!
> > (why don't you need to chmod +rx it ? ) or enter them
> > on the cli.....
>
> You don't need to make it executable because it's not executed, it's
sourced.
> That is, it is read as input by another script, usually .bash_profile.
>
> > You have the makings of a really good book there...
> > (e or otherwise )
>
> Maybe someday. I'd be happy just to have enough time to write the next
> lesson.
>
Am looking forward to it.....
Bruce<+>
> --
> ||||| William Shotts, Jr. (bshotts AT panix DOT com)
> ||||| Be a Linux Commander! Follow me to http://linuxcommand.org
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: Jabber - The world's fastest growing
> real-time communications platform! Don't just IM. Build it in!
> http://www.jabber.com/osdn/xim
> _______________________________________________
> Linuxcommand-discuss mailing list
> Lin...@li...
> https://lists.sourceforge.net/lists/listinfo/linuxcommand-discuss
|