How to find file location using the regular expression ("*" in the path)?

Question:

Following cp linux command is working fine to find a file "/home/temp/test-1.34.56/sample" to current location

Shell command: Working fine

cp "/home/temp/test-*/sample" "./"

Python code:
It not working using os.rename

os.rename("/home/temp/test-*/sample", "./")

any other options ?

Asked By: Lava Sangeetham

||

Answers:

Tried glob module from above @Wjandrea, @Tom, @Treuss comments. it worked

from glob import glob
import shutil


Actual_path = glob("/home/temp/test-*/sample")
shutil.move(Actual_path,"./")
Answered By: Lava Sangeetham
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.