Regular Expression Matching NOT


You want to find a line, not matching the pattern.



I find this invaluable whilst editing crons. Or in vi – like this: [^x] where x equals the character you want to ignore.



For example after performing a crontab -e, wanting to skip comments.

crontab -e

Also with sed – substituting tags, etc:

sed 's#]*>##g' filename

This says edit your crontab, match the next line that has a beginning, immediately followed by a character that is not a comment.

After performing this once, just type n – for the next match (i.e. next line that does not start with a comment).



[tags]UNIX, vi, regular expression, Unix Coding School[/tags]


If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

Your email address will not be published. Required fields are marked *