I can't use the "dirname" command because this is a string and not a really directory. So, I extract my dirname and filename only using regexp.
Example:
filefolder=/home/ubuntu/Desktop/photo.jpg
If I want to extract the filename, I use: filename=${filefolder##*/}
. It works, and returns as result: "photo.jpg".
If I want to extract the dirname, what kind of regexp can I use?
I've tried with NOT operator before "*/
" in this way: dirname=${filefolder##^[*/]}
but doesn't work.
Any idea to solve it?