HELP! Scripting newbie question.



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



.



Relevant Pages

  • problem with readline
    ... I have a script that queries a database, grabs a bunch of email addresses from ... push @email_list, $address; ...
    (perl.beginners)
  • Re: HELP! Scripting newbie question.
    ... printf "File: $file\n" ... There is nothing in your script to do the expand of the $1. ... insert a test by doing an echo $list or echo $1 in your srcipt to ...
    (comp.unix.solaris)
  • Re: Redirecting STDOUT & STDERR
    ... at the end of the script. ... That should be print instead of printf: ... You probably should use a while loop instead of a foreach loop. ... print MAIL "$from\n"; ...
    (perl.beginners)
  • Re: can you help about this script
    ... shell session. ... Try systemin your awkscript: ... printf "Created: %s\n", ... which runs "hostname" once, stashes the result away ...
    (freebsd-questions)
  • Re: missing values from files
    ... I wrote a script that reads data from different files and put it all ... The part of the script that output to the <ALLF> file is the ... printf; ... The original data looks like this for both columns (its not the same ...
    (perl.beginners)