I am trying to remove some file (from my linux machine), except few:
touch INCAR KPOINTS foo bar
$ls
bar foo INCAR KPOINTS
$python3 mini.py
Job Done
$ls
bar foo INCAR KPOINTS
The mini.py is:
#!/usr/bin/python3
import subprocess
subprocess.run(['rm', '-f', '!(INCAR|KPOINTS|PO*|*.sh)'])
print("Job Done")
As can be seen in the output of mini.py, its notgiving any error but neither its doing its job.
What I am doing wrong here?
rmis not a executable, it's just a internal command of bash. Tryrun['bash', '-c', " rm ..."]rmis an executable in any sane system. It is part of the GNU Coreutils package and you can find it in/bin/or/usr/bindepending on your distro.os.remove(). It seems that thermruns but cannot delete some of those files.os.remove? I mean!(...)part?