How to extract path name starting with specific folder
Hello guys,
Im writing a script that extracts part of the path name: I drop a file in terminal and set the directory name of the file to x using dirname $0 note: ( directory is different every time since not all files are from the same location) ex. x="/home/Downloads/yesterday/photo/.../image.png" /image.png /.../ means I dont know the name of folders between but I know the path name always starts with photo and I want to capture directory after "photo" and store it like this: y=/photo/image.png" then something like code: cp file $y All helps appreciated |
Assuming for example you want to extract x/y/z/image.png from /home/Downloads/yesterday/photo/x/y/z/image.png (which is not what you illustrated but may have been what you meant):
Code:
x=/home/Downloads/yesterday/photo/x/y/z/image.png |
Quote:
Thank you very much, it worked like a charm :D |
Quote:
|
All times are GMT -5. The time now is 07:13 PM. |