Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unix Help 1

Status
Not open for further replies.
Jul 12, 2001
5
US
Hi,

I want to know how can we do pull up a string up to a position.

For example

I have a variable /disk5/oracle/admin/arch/arch_123.dbf

I require the output to be stored in a variable
as /disk5/oracle/admin/arch/

Can anyone help out how to solve this

Thanks in advance

Sridhar
 
"dirname" command will give you the path information of a file (command complementary to "basename").
Hope this will help :)
 
It's not a actual file name, it's only a dummy path and it gives an error!!

Thanks for your help anyway
 
I am getting a blank output.

$export dest=/disk5/oracle/admin/arch/arch_123.dbf
$echo $dest|dirname
$
$

Whereas I require the output to be
/disk1/oracle/admin/arch/

Thanks a lot for your help

Sridhar
 
Here is what I've found...

$ dest="/disk5/oracle/admin/arch/arch_123.dbf"
$ echo $dest
/disk5/oracle/admin/arch/arch_123.dbf
$ echo $dest|dirname
.
$ dirname $dest
/disk5/oracle/admin/arch

So, the latter should work.
 
$echo `dirname $dest`

It worked!!

Thanks a lot for your help.

Sridhar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top