Regular expression cheatsheet
Jump to navigation
Jump to search
This is small collection of regex that patterns I want to document because I think they are useful, at least for me.
Check unknown values only
For a serverspec test I needed to write a check where all unknown shell aliases should match in one query without looping. This is what I came up with. I know that the 3 grep patterns could be further reduced.
^alias\s+(?!(?:egrep|fgrep|grep|which)=)
Which matches only the last 2 highlighted entries but not the leading 4 ones:
alias egrep= alias grep= alias fgrep= alias which= alias whatever= alias foobar=