linux - How to parse out the end of a path in a unix shell script? -



linux - How to parse out the end of a path in a unix shell script? -

i have .sh unix shell script receives parameter path, /home/test/user1. so, in variable ${1}, parameter.

i want create file name based on lastly part of path, user1. how can parse path retrieve lastly piece of path?

i think looking basename command.

$ basename /home/test/user1 user1

edit: (in response comment)

in shell-script variable, need backticks:

end_of_path=`basename "${1}"`

linux unix shell

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -