I want to delete the bash history using a python script on my Macbook Pro.
I know two ways to delete bash history with bash shell
1.rm ~ / .bash_history
2. history -c
But this command does not work in python script with subprocess:
1.rm ~ / .bash_history
import subprocess
subprocess.call([‘rm’, ‘~/.bash_history'])
Error:
rm: ~ / .bash_history: no such file or directory
2. history -c
import subprocess
subprocess.call(['history', '-c'])
Error:
"test.py", 8, subprocess.call(['history', '-c']) "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py" , a > 524, return Popen (* popenargs, ** kwargs).wait() "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py" , a > 711, init errread, errwrite) "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py" , a > 1308, _execute_child raise child_exception
?