Beginner shell script help

. ./testFile.sh
url=http://ichart.finance.yahoo.com/table.csv?s= suf=&d=5&e=9&f=2009&g=d&a=1&b=4&c=1999&ignore=.csv
wget $url$s1$suf;
sleep 10;
cat header.txt > $s1.txt;
chmod 777 $s1.txt;
sed '1d' table.csv?s\=$s1 >> $s1.txt;
rm -Rf table*

Very new at shell scripting as you can see :slight_smile: testFile.sh currently is a list of stock tickers s1=rimm s2=aapl etc.

Basically scraping data for each ticker from yahoo and writing to a text file in a format I can utilize.

The thing is there are many many tickers I want to grab data from so would like a list of tickers in testFile.sh that script performs the same action on till completed. Rather then defining each variable and writing the same thing over and over changing s1 to s2 to s3 etc.

I tried for each do but didn't seem to work.

Thanks for any assistance really appreciated.

$ 
$ for ticker in rimm aapl blah foobar ; do
>   echo "Do your stuff with $ticker..."
> done
Do your stuff with rimm...
Do your stuff with aapl...
Do your stuff with blah...
Do your stuff with foobar...
$ 
$ 

tyler_durden

you can try loops

while read s1 s2 s3 ...etc
do
commands
done < file.txt

BR

Why not put the list of tickers in a separate file?

url s1 suf
url s1 suf
... etc

while read url s1 suf blah; do
 url="http://ichart.finance.yahoo.com/table.csv?s=  suf=&d=5&e=9&f=2009&g=d&a=1&b=4&c=1999&ignore=.csv"
  wget $url$s1$suf;
  sleep 10;
  cat header.txt > $s1.txt;
  chmod 777 $s1.txt;
  sed '1d' table.csv?s\=$s1 >> $s1.txt;
done < tickers.txt
rm -Rf table*