[NTLUG:Discuss] bash script help [not homework ;) ]?
Rob Holland
rob.holland at insi.com
Thu Apr 25 12:07:24 CDT 2002
I think you want to append (>>) to the file not write (>) to the file.
----- Original Message -----
From: "Rev. wRy" <slot0k at pogox.org>
To: <discuss at ntlug.org>
Sent: Thursday, April 25, 2002 11:41 AM
Subject: [NTLUG:Discuss] bash script help [not homework ;) ]?
> 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)
>
>
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
>
More information about the Discuss
mailing list