bash - How to convert a directory to a string? -


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

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -