Re: [Linuxcommand-discuss] Greetings & a Script
Brought to you by:
bshotts
|
From: Bruce B. <bbu...@ea...> - 2002-08-27 02:17:05
|
----- Original Message -----
From: "William Shotts" <wes...@co...>
To: <lin...@li...>
Sent: Monday, August 26, 2002 6:08 PM
Subject: Re: [Linuxcommand-discuss] Greetings & a Script
> On Sunday 25 August 2002 01:26 pm, Bruce Burhans wrote:
>
> > #!/bin/bash
> > # 2.05
> > old=$1
> > new=$2
> > for i in $( ls ); do
> > if [[ $i != *$old ]]; then
> > shift
> > else
> > k=$( basename $i ${old} )
> >
> > mv $i ${k}${new}
> > fi
> > done
>
> 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 ;-)
>
> --
> ||||| William Shotts, Jr. (bshotts AT panix DOT com)
> ||||| Be a Linux Commander! Follow me to http://linuxcommand.org
>
>
Will give it a try, Bill........But will it skip over
files that do not have the old extension?
Here's one that I use all the time.....I call it fe for
"file explorer"......
There are actually two- the main one puts the $PWD
in a temp file in my $HOME when I choose EXIT,
then . dc (that's a dot and a space for 'source' ) cds
me to that directory .
-----------------------------------------------------
#!/bin/bash
###2.05
### fe
while : ; do
select fname in $HOME / EXIT $(ls -aF) ; do
if [ "$fname" = EXIT ] ; then
echo "$PWD" > /home/farley931/.t2
exit; fi
if [ -f "$fname" ] ; then
less "$fname"
elif [ -d "$fname" ] ; then
cd "$fname"
echo "$PWD"
break
fi
done
done
----------------------------------------------------------
### dc
cd $(cat /home/farley931/.t2)
--------------------------------------------------------
Bruce<+>
|