Let's say I want to do an ls
command and then use python's re
library to filter the results, the equivalent of this
$ ls|grep c
cmd.py
Is this possible to do across pipes? For example, something like this:
$ ls|python -c "import re,sys;r=re.search('^c', sys.argv[0]); print (r.group(1))"
^
# 'pretending' the output of `ls` is passed in sys.argv
Is this possible to do without a lot of legwork (such as reading/writing to a file)?