From: Philip Prindeville
> Sent: 22 April 2024 17:16
> Somewhat off-topic post but this is on a system that has Busybox installed so 
> I can't use features
> that other shells might provide.
> 
> I have a stream generated by "find" of pathnames, and I want to delete 
> (filter out) certain paths
> based on the contents of a file that holds exclusions.
> 
> Anyone know an easy way to do this?  Something like "... | grep -v -f 
> exclusions.txt" if grep worked
> with globs instead of patterns...

A shell 'case' statement will do filename 'glob' matching.
so something like:
        find ... | while read path; do
                case $path in
                (exclusion_1 | exclusion_2 ...) ;;
                (*) echo $path;;
                esac
        done
might work (modulo some extra quoting - probably ' around the patterns).
That does require a pre-process of your exclusions.txt file.
With a bit of care you can use the shells eval on the entire case statement
to do that in the script itself.
If you use eval make sure you quote everything except the variables you
want expanded on the first pass.

        David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, 
UK
Registration No: 1397386 (Wales)

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to