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
Last edited by john206; 11-23-2010 at 09:14 PM.
|