Re: renaming files via shell script
- From: "Chris F.A. Johnson" <cfajohnson@xxxxxxxxx>
- Date: Thu, 23 Feb 2006 11:45:49 -0500
On 2006-02-23, robert wrote:
I still have one question: I can't get for 'file in "$@"' or 'for
file' to work. I can, however, get for file in "*mpc*" to work (mpc is
what I meant by somefile.
Here's my test case:
#!/bin/sh
echo "in script"
for file in "$@"
do
echo "in for loop"
done
I get 'in script' but not 'in for loop' .
The command I run is this, from the directory that has convert_mpc.sh
find . -type f -name "*mpc*" -exec ./convert_mpc.sh \;
My mistake; I left out {}:
find . -type f -name "*mpc*" -exec ./convert_mpc.sh {} \;
The files I have are like so (from same dir as convert_mpc.sh)
/home/iksrazal/mpc> find .
.
./mppdec-linux-libc6-static-1.95e.zip
./mppdec-static
./bc
./bc/01 - Stella By Starlight.mpc
./bc/02 - Autumn Leaves.mpc
./bc/03 - New Waltz.mpc
./bc/04 - Bouncing With Bud.mpc
./bc/05 - 'Round Midnight.mpc
./bc/06 - And Then Again.mpc
./bc/07 - I Thought About You.mpc
./bc/08 - Someday My Prince Will Come.mpc
./ozric_abs.mp3
./stella.mp3
./convert_mpc.sh
Now if I change the script to be the following, I get the 'in for loop'
message:
#!/bin/sh
echo "in script"
for file in "*mpc*"
do
echo "in for loop"
done
What am I doing wrong?
If you use that, find does nothing at all; you are not using its
output. Use that if you want to process files in the current
directory (and don't use find).
--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
.
- References:
- renaming files via shell script
- From: robert
- Re: renaming files via shell script
- From: Chris F.A. Johnson
- Re: renaming files via shell script
- From: robert
- renaming files via shell script
- Prev by Date: Re: does Linux support wireless lan?
- Next by Date: Error message mounting local file system upon boot (Debian)
- Previous by thread: Re: renaming files via shell script
- Next by thread: Re: renaming files via shell script
- Index(es):
Relevant Pages
|