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

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -