Re: [Linuxcommand-discuss] Greetings & a Script
Brought to you by:
bshotts
|
From: William S. <wes...@co...> - 2002-08-27 01:08:29
|
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
|