[NTLUG:Discuss] bash script help [not homework ;) ]?

Rev. wRy slot0k at pogox.org
Thu Apr 25 11:41:42 CDT 2002


Hello -

I'm beating myself senseless trying to figure out how I can get this 
script to work without clobbering the output file (score.html).  The 
files can't be sorted, as the data is unique to each user.  The script 
works fine except for the fact that score.html only ends up including 
the last iteration's result.  Any suggestions?

Here's the script:

#!/bin/bash

oldIFS=$IFS
IFS=$'\n'
declare -a target
target=(`cut -d '#' -f1 urls`)
declare -a site
site=(`cut -d '#' -f2 urls`)
iter=${#target[@]}
a=0
while [ $a -lt $iter ]; do
    while IFS=# read name desc; do
    if [ $name = ${target["$a"]} ]; then
    sed "s#$name#\<a href=\"$site\"\>&\<\/a\>#" elist.txt > score.html
    fi
   done < elist.txt
  let a=a+1
done

Here's the layout of the files:

urls
----
name # http:somethingorother.xxx
...

elist
-----
user # user at host # date
name # description
...

score.html
----------
user # user at host # date
http:somethingorother.xxx name # desc

TIA-
Ry
(who has already checked google and comp.unix.shell for an example of 
how to make it work and found nothing)





More information about the Discuss mailing list