Complete.Org: Mailing Lists: Archives: discussion: April 1999:
Re: [aclug-L] opposite of basename?
Home

Re: [aclug-L] opposite of basename?

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "'aclug-L@xxxxxxxxxxxx'" <aclug-L@xxxxxxxxxxxx>
Subject: Re: [aclug-L] opposite of basename?
From: Sanjay Dhar <sxdhar@xxxxxxxxxxx>
Date: Tue, 27 Apr 1999 15:41:34 -0500 (CDT)
Reply-to: aclug-L@xxxxxxxxxxxx

> Is there a command which does the opposite of basename,
> i.e strips off the simple file name at the right end and
> returns the path leading to it?  
> 
> I need to write a script which refers to some files relative
> to where the script is located.  Applying such a function
> to $0 would do it.  Suggestions on other approaches are also
> welcome 
> 
> 

You could do it in one line using awk
  
 echo `basename $0` | awk -F/ '{print $NF}'
  
 That should return the string that you want i.e. in this case the name of 
the file.

---
Sanjay


[Prev in Thread] Current Thread [Next in Thread]