If I have a string such as
/home/user/a/directory/myapp.app
or just
/home/user/myapp.app
how can I split this so that I just have two variables (the path and the application)
e.g.
path="/home/user/"
appl="myapp.app"
I've seen numerous examples of splitting strings, but how can I get just the last part, and combine all the rest?
Best Answer
The commands
basename
anddirname
can be used for that, for example:For more information, do not hesitate to do
man basename
andman dirname
.