I'm trying to execute the following command using subprocess module (python)
/usr/bin/find <filepath> -maxdepth 1 -type f -iname "<pattern>" -exec basename {} \;
But, it gives the following error :
/usr/bin/find: missing argument to `-exec'
I am guessing it's to do with escaping some characters. But not getting how to get over this.
Any help is appreciated. Thanks.
An answer on another question helped:
https://stackoverflow.com/a/15035344/971529
import subprocesssubprocess.Popen(('find', '/tmp/mount', '-type', 'f','-name', '*.rpmsave', '-exec', 'rm', '-f', '{}', ';'))
The thing I couldn't figure out was that the semi-colon didn't need to be escaped, since normally the semi-colon is interpreted by bash, and needs to be escaped.
In bash this equivelent is:
find /tmp/mount -type f -name "*.rpmsave" -exec rm -f {} \;