Python subprocess Popen: Why does “ls *.txt” not work? [duplicate]

*.txt is expanded by your shell into file1.txt file2.txt … automatically. If you quote *.txt, it doesn’t work: [~] ls “*.py” ls: cannot access *.py: No such file or directory [~] ls *.py file1.py file2.py file3.py If you want to get files that match your pattern, use glob: >>> import glob >>> glob.glob(‘/etc/r*.conf’) [‘/etc/request-key.conf’, ‘/etc/resolv.conf’, … Read more

awk in bash with ls and variable

This is exactly why you should not use UPPER_CASE_VARS. $PATH is a variable used by the shell to find executables on your system. As soon as you over-write it with user input, your script can no longer find anything that does not reside in whatever the input was. In this case, you entered /bin, so … Read more