I'm currently making use of a complex find command to delete files that has a specific MIME type.
find -type f -exec bash -c ' for f; do file=$(file -- "$f") if [[ $file =~ ^$f:\ "C source" ]]; then echo rm -- "$f" fi done ' bash {} +
I wanted to make use of python to run the following command as per my requirements. When I try to use subprocess to invoke the command I do not any output. I'm not sure if this is the right way to do it as I'm new to linux. Any help would be appreciated.
from subprocess import call call(''' find -type f -exec bash -c ' for f; do file=$(file -- "$f") if [[ $file =~ ^$f:\ "ASCII text" ]]; then echo rm -- "$f" fi done ' bash {} + ''', shell=True)
I currently have a set of files in my directory and I'm running this python script from the same directory. I'm expecting a set of filenames as an output since there are few matches for 'C source'