Skip to content Skip to sidebar Skip to footer

Wildcard Or * For Matching A Datetime Python 2.7

I am trying to match the following string and not having any luck. Below you will find my attempt. LOG FORMAT: riskserver.2014-04-07-08:45:01.log I think I only will need the ye

Solution 1:

glob is the splat (*) , eg ls *.txt gets processed by the linux shell into ls f1.txt f2.txt f3.txt f4.txt ...

so that ls actually recieves a list of files that match not the matching string. that is what they mean in the comments

nowFormat = "2014-04-07"
cmd = 'tail -n10000 /opt/rubedo/log/riskserver.'+nowFormat+'*'
os.system(cmd) #this will execute it through your linux shell you should see the output, allthough this call will not give you access to the output in python

or in python

import glob
fnames = glob.glob('/opt/rubedo/log/riskserver.'+nowFormat+'*')
print fnames

Post a Comment for "Wildcard Or * For Matching A Datetime Python 2.7"