The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find the geographical location within a shell script eamani_sun Shell Programming and Scripting 1 05-13-2008 07:27 AM
script to check for a condition inside a file kiran1112 Shell Programming and Scripting 11 03-21-2007 06:38 AM
excutable script to copy a file to a different location. nazehcalil UNIX for Dummies Questions & Answers 4 12-21-2006 06:17 AM
running sed inside script file bajaj111 UNIX for Dummies Questions & Answers 4 11-08-2006 03:58 AM
Creating a file inside a script sendhilmani Shell Programming and Scripting 11 03-21-2006 05:24 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 03-14-2006
Registered User
 

Join Date: Feb 2006
Posts: 25
Use command dirname

hi asami,
you can use driname command


path= `dirname $0`
echo $path



This will give you only the path of your script which is what you were looking for.
Reply With Quote
Forum Sponsor
  #9  
Old 03-14-2006
Registered User
 

Join Date: Mar 2006
Posts: 1
Maybe I did not understand

Asamy

have you tried with the command substition?

In your script try do insert this row

echo "We are in `pwd`"

I hope it is what you need.
^Nosfe^
Reply With Quote
  #10  
Old 03-14-2006
Registered User
 

Join Date: Mar 2006
Posts: 14
hey vino thnx man, u guided my thirsty soul. the following works for me

Code:
#!/bin/bash

base=${0%/*}
current=`pwd`

cd $base
echo "The Path is `pwd`"
cd $current
Reply With Quote
  #11  
Old 03-14-2006
Registered User
 

Join Date: Mar 2006
Posts: 14
using dirname

Quote:
Originally Posted by reddymails
hi asami,
you can use driname command


path= `dirname $0`
echo $path



This will give you only the path of your script which is what you were looking for.
Code:
using dirname
cur=`pwd`
path=`dirname $0`
cd $path
echo "`pwd`"
cd $cur
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:35 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0