A little duplicate...how about this:
```
grep_cmd = test_cmd.split("-")[0]
cmd = 'grep "%s" /var/log/audit/audit.log  | grep "%s" | tail -n1 | grep "res=success"' % (grep_cmd, device_source)
```
BTW, this line is toooo long :(