bash - How to convert a directory to a string? -
this question has answer here:
i have symlink
named current
pointing directory , lets
current -> $home/local/java/jdk1.8.0
i want extract jdk1.8.0
part string.
first, directory :
current_dir= $(readlink -f $current)
and then, tried extract last part of path :
last_part= ${current_dir##*/}
or when try print via :
echo $current_dir
i error:
bash: /home/tarrsalah/local/java/jdk1.8.0: directory
how can convert directory string ?
use basename
:
$ basename /home/tarrsalah/local/java/jdk1.8.0 jdk1.8.0
Comments
Post a Comment