I'm trying to split a filename use it by parts.
The file is always an apache binary (for example, httpd-2.2.31.tar.gz) and I only need the version (in this case 22) in that specific format.
I have done it and it works, but I believe there should be a better way
binary_name = "httpd-2.2.31.tar.gz"
app, ver_tar = binary_name.split("-")
version = ver_tar.split(".")
print ("Version %s%s" % (version, version))
if you want to do it in one line,may be it will help :
binary_name = "httpd-2.2.31.tar.gz" print binary_name.split("-")[:3].replace('.','')
will return 22