TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:16440] quick scripting question



In unix:
cat names.list | awk '{ printf("wc -l %s file.txt\nwc -l %s file.txt\n",
$1, $2) }' > runme.sh

Format to your desire.

Carl Wilhelm Soderstrom wrote:
> 
>         I'm feeling really stupid asking this, because I really *should*
> know how to do this but...
> 
> I have a list of names in a file
> format:
> <firstname> <lastname>
> <firstname> <lastname>
> <firstname> <lastname>
> etc..
> 
> I want to take each firstname & lastname pair, and search for them in
> another file, counting the number of occurrences (using wc -l).
> 
> this is on a win32 machine, and I have the Cygwin awk & bash. (no perl).
> 
> how do i do it?
> 
> environment variables apparently won't take a multi-line list
> (otherwise I could do something like:
>         for name in $namelist
>         do
>                 echo $name >> outputlist.txt
>                 grep $name filename|wc -l >> outputlist.txt
>         done
> )
> 
> I've looked at awk; but I can't seem to figue out how to take a variable
> read from one file, and apply it to an operation on another file.
> 
> yes, I know, this would be quite a bit easier if I had perl...
> 
> Carl Soderstrom
> System Administrator    307 Brighton Ave.
> Minnesota DHIA          Buffalo, MN
> carls@agritech.com      (763) 682-1091
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tclug-list-unsubscribe@mn-linux.org
> For additional commands, e-mail: tclug-list-help@mn-linux.org

-- 
Adam Maloney
Systems Administrator
Internet Exposure, Inc.