bash - Concatenate all files except one calling system - Python -
to concatenate txt files of folder, can done cat easily:
cat ./tmp*.txt >./tmp/all.txt
however, want concatenate files except 1 can done following command explained here:
cat ./tmp/!(1.txt) >./tmp/all_except_1.txt
these commands work on command line, trying call them python os.system
command , gives error
>>> import os >>> os.system('cat ./tmp/!(1.txt) >./tmp/all_except_1.txt') sh: 1: syntax error: "(" unexpected
does know why , how can solved?
you need enable extended pattern matching in bash before call it:
os.system("bash -o extglob -c 'cat ./tmp/!(1.txt) >./tmp/all_except_1.txt'")
Comments
Post a Comment