Re: HELP! Scripting newbie question.



On Jul 31, 2:59 pm, Julie Warden <julie_war...@xxxxxxxxxxxxxxxxx>
wrote:
Group,

I'm trying to write a script to process a file list for an argument
passed in. It seems like it should be real easy, but it's not getting
expanded. I just get the 1st file and that's it.

I use Bourne or Korn shell. I included a few examples so you know I've
been RTFM'ing a bit - eval should have done it according to the scripting
book I've got. If I hard code the argument it works fine.

Here's what I've tried:
assuming you're in a database directory with a bunch of *.db files...

tst /db/*.db

#!/bin/sh
### tst

for file in `$1`
do
printf "File: $file\n"
done

or...

for file in `eval ls $1`
do
printf "\n"
done

or...

files=$1

for file in `echo $files`
do
printf "File: $file\n"
done

None of these works...

Hard coding works fine:
for file in `ls /db/*.db`
do
printf "File: $file\n"
done

Any help appreciated,
Julie

There is nothing in your script to do the expand of the $1.
simplisticly, list=`ls $1`
for file in $list
do
printf "File: $file\n"
done
insert a test by doing an echo $list or echo $1 in your srcipt to
check for how the varible is expanding.

as in ;
list=`ls $1`
echo $list
and so forth.

.