I'm a newbie in bash and I would like to pass as parameter to a python function all files in a directory that don't match a given pattern. sth. like:
$myscripts/myprog.py $myf开发者_Go百科iles/!(bonjovi)
The above example should retrieve all files that don't match to "bonjovi".
Best wishes
You have the syntax exactly right. You just need to enable it.
shopt -s extglob
It's probably easiest to use grep
, xargs
and a regular expression. grep -v
excludes lines (in this case filenames) matching a given pattern.
ls | grep -v 'bonjovi' | xargs myscripts/myprog.py
精彩评论