I am new to python. I am trying to execute a bash script in python to extract the count of different file extensions. I tried the following command
import subprocess
output = subprocess.check_output("sudo find . -type f -name '*.*' -exec sh -c 'echo ${0##*.}' {} \; | sort | uniq -c | sort -nr | awk '{print $2 ":" $1}'", shell=True)
But it throws a syntax error. On executing find command in bash shell
sudo find . -type f -name '*.*' -exec sh -c 'echo ${0##*.}' {} \; | sort | uniq -c | sort -nr | awk '{print $2 ":" $1}'
output will be as follows
png:3156
json:333
c:282
svg:241
zsh:233
js:192
gz:169
zsh-theme:143
ttf:107
cache:103
md:93
So how can i get the same output in python code? what is the correction required in my current approach? Thanks in advance