To concatenate all the TXT files of a folder, it can be done with cat easily:
cat ./tmp*.txt >./tmp/all.txt
However, I want to concatenate all files except one which can be done with the following command as explained similarly here:
cat ./tmp/!(1.txt) >./tmp/all_except_1.txt
These commands work perfectly on the command line, but I am trying to call them from python with os.system
command and gives an error
>>> import os
>>> os.system('cat ./tmp/!(1.txt) >./tmp/all_except_1.txt')
sh: 1: Syntax error: "(" unexpected
Does someone know why and how can be solved?