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
Post a Comment