Re: [aclug-L] opposite of basename?
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
> 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
|
|