Operating System - HP-UX
1834094 Members
2214 Online
110063 Solutions
New Discussion

Parse between the path and the filename.

 
SOLVED
Go to solution
Adam Prince
Occasional Contributor

Parse between the path and the filename.

 
3 REPLIES 3
G. Vrijhoeven
Honored Contributor

Re: Parse between the path and the filename.

Hi,

What is the question?

echo $0

Gideon
Deepak Extross
Honored Contributor

Re: Parse between the path and the filename.

Let me take a shot in the dark...
'man basename' ??

Steven Sim Kok Leong
Honored Contributor
Solution

Re: Parse between the path and the filename.

Hi,

I agree with Deepak. The "basename" command suits your needs. Example:

# file=/var/adm/syslog/syslog.log

To get the filename:


# basename $file
syslog.log

To get the directory path:

# echo $file | sed -e "s/`basename $file`//g"
/var/adm/syslog/

Hope this helps. Regards.

Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com