Hi,
I am having a variable
Like
line="/dir1/dir2/gr3/file.ksh"
I need to get the /dir1/dir2/gr3 alone. the no of directories may differ at each time.
Please advice. thanks in advance.
Hi,
I am having a variable
Like
line="/dir1/dir2/gr3/file.ksh"
I need to get the /dir1/dir2/gr3 alone. the no of directories may differ at each time.
Please advice. thanks in advance.
echo $line | sed 's [^/]*$ '
thank you danmero. it is working.
There are also the dirname(1) and basename(1) commands
$ line="/dir1/dir2/gr3/file.ksh"
$ echo $line
/dir1/dir2/gr3/file.ksh
$ basename $line
file.ksh
$ dirname $line
/dir1/dir2/gr3
$