I am trying to parse a command line, with 0 or more commands before of after a command.
The <name> is part of the line as well.
Example:
cmd = 'lsg <name>; cd <name>;find . -type f -exec grep -i <name> {} \; -print;lsg ; ps axwwl '
pattern = r'.*(find.*-exec.*\\;?.*?;?)(;*.*$)'
match = re.match(pattern, cmd)
What I am getting is:
find . -type f -exec grep -i <name> {} \;
What I am trying to do is just match the find command, i.e.:
find . -type f -exec grep -i <name> {} \; -print
Any help would be greatly appreciated.