How do I negate a test with regular expressions in a bash script?

Using GNU bash (version 4.0.35(1)-release (x86_64-suse-linux-gnu), I would like to negate a test with Regular Expressions. For example, I would like to conditionally add a path to the PATH variable, if the path is not already there, as in: TEMP=/mnt/silo/bin if [[ ${PATH} =~ ${TEMP} ]] ; then PATH=$PATH; else PATH=$PATH:$TEMP; fi TEMP=/mnt/silo/Scripts: if [[ … Read more

How to negate a method reference predicate

In Java 8, you can use a method reference to filter a stream, for example: Stream<String> s = …; long emptyStrings = s.filter(String::isEmpty).count(); Is there a way to create a method reference that is the negation of an existing one, i.e. something like: long nonEmptyStrings = s.filter(not(String::isEmpty)).count(); I could create the not method like below … Read more