i need help understanding why i cant iterate through the ls -ltcrd output which im storing in a variable:
def test():
tmplist = os.system('ls -ltcrd /tmp/*')
tmplist.split(' ')[:1] #trying to grab the last column here
print test()
What I'm trying to do with the above python code is equivalent to this in shell:
ls -ltcrd /tmp/* | awk '{print $NF}'
Note that the output contains the absolute path of all the files under /tmp.
Ideally, Id like to avoid calling any external utilities. But running it as shown above seems to be the simplest way to get what i want.
not even sure if "iteration" is the right term to use to describe this.