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!

to get pwd value 1

Status
Not open for further replies.

hendnov

Technical User
Feb 27, 2006
73
AU
Hi guys,

Here's part of my code which called summary.ksh :

Code:
if [$1 == "\."]
then 
input = pwd
echo "input =" $input
fi

I want to have the full path directory if the input is "."
so

if I'm at the directory /opt/adoc
when I execute the script, I want the $input = /path/of/directory, the result would be something like this :

Code:
/opt/adoc> summary.ksh .
input = /opt/adoc

Could you guys help me ?
 
Why not simply this ?
input=$(cd "$1" && pwd -P)
echo "input = " $input

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
like this (for ksh)?

echo "dir? (use '.' for current dir)"
read input
if [ ${input} = '.' ]
then
input=$(pwd)
echo "input = " ${input}
fi


HTH,

p5wizard
 
Hi,

Shell in an interpreted language, not a compiled one.
So avoid all spaces around tokens.
Code:
input=$(pwd)
echo "input =" $input

for working directory purpose, you can use the predefined shell variable $PWD


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top