On Thu, 9 Dec 2010, Jan L. Peterson wrote:

> On Dec 9, 2010, at 6:49 PM, [email protected] wrote:
>> basename to eliminate one cut is a good point (I know about the command, but 
>> it's not something I commonly use), is it really any faster for this (since 
>> they both need to execute a command)
>
> I don't know if it's much faster, but basename isn't handling any input like 
> cut would be doing.  Everything it needs is handed to it as an argument.
>
>> but what happens if the grep "^Filter:" returns more than one item? won't 
>> all of them become part of f?
>
> The "exit" in the awk command takes care of it.  It will exit after the first 
> print.  And, in fact, since I'm using awk, my use of grep isn't really 
> required, either!
>
> Taking everyone's suggestions into account, try this:
>
> (eval `for m in *.meta; do f=\`awk '/^Filter:/ { print $2; exit }' $m\`; echo 
> -n "./$f -r \`basename $m .meta\` |"; done | sed -e "s/|$//"`) < input > 
> output

this doesn't work right.

the filter scripts all create files that contain rules that match the 
filter, and then send the unknown lines to stdout

the number of lines identified by each script match, but the number of 
lines in the output file is incorrect (it's missing a couple thousand 
lines out of ~80 thousand). doing a diff of the output doesn't show 
anything obvious about what's missing

the following works correctly

eval `echo -n "cat input | "; for file in *.meta ; do grep "^Filter: " $file 
|head -1 |cut -f 2 -d " " |while read filter; do echo -n "./$filter -r 
\"\`basename $file .meta\`\" -n -u | "; done; done; echo "cat >output"`

David Lang
_______________________________________________
Discuss mailing list
[email protected]
https://lists.lopsa.org/cgi-bin/mailman/listinfo/discuss
This list provided by the League of Professional System Administrators
 http://lopsa.org/

Reply via email to