I have this nushell query:
open ./s3_actions.csv | where actions !~ 'Acl' | where actions !~ 'Cors' | where actions !~ 'Job' | where actions !~ 'Retention' | where actions !~ 'Legal' | where actions !~ 'Payment' | where actions !~ 'Policy' | where actions !~ 'Configuration' | where actions !~ 'Replicate' | where actions !~ 'AccessPoint'
Is there a way I could combine all the where actions !~ ... clauses into one big list ?
The closest I got was here but I don't know how to do nested loops, both would have the same $it variable.
You didn't provide any sample data to validate against, but I assumed something like:
It's possible there's another way for your particular data source, but the following line (split to multiple lines for improved readability) returns the same results as the multiple
whereclauses in your question:Explanation:
Ultimately, what you are asking for is a way to "reduce" a "list of where actions" down to a single value,
trueorfalse. Look to thereducecommand for that.In this particular case:
whereis run for each record returned froms3_actions.csvreduceis then run for each action in the list. It starts with the accumulator (acc) set totrue, but if any of the tests returnsfalse, it will become false when the two are&&(and)'ed.And yes, because there are two blocks here (for
whereandreduce), you'll need to use a different name for the arguments for each.