![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#8
|
|||
|
|||
|
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. |
| Forum Sponsor | ||
|
|
|
#9
|
|||
|
|||
|
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^ |
|
#10
|
|||
|
|||
|
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
|
|
#11
|
|||
|
|||
|
using dirname
Quote:
Code:
using dirname cur=`pwd` path=`dirname $0` cd $path echo "`pwd`" cd $cur |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|