regex : does not begin by "pattern"
Solution 1:
Using grep
in this case with -P
option, which Interprets the PATTERN as a Perl regular expression
grep -P '^(?:(?!git).)*$' LIST
Regular expression explanation:
^ the beginning of the string
(?: group, but do not capture (0 or more times)
(?! look ahead to see if there is not:
git 'git'
) end of look-ahead
. any character except \n
)* end of grouping
$ before an optional \n, and the end of the string
Using the find
command
find . \! -iname "git*"
Solution 2:
Since the OP is looking for a general regex and not specially for grep, this is the general regex for lines not starting with "git".
^(?!git).*
Breakdown:
^
beginning of line
(?!git)
not followed by 'git'
.*
followed by 0 or more characters
Solution 3:
If you want to simply list all lines that don't contain git try this
cat LIST | grep -v git