pwd in a variable

is there anyway i could store the output of pwd that is the path in a variable...?

Yes...

You can store the password in the variable.. Here your password is stored in variable 'pass'.

Example:
---------

#cat pass.sh
password=123
echo -n "Enter pass:"
read pass
if [ $pass = $password ]; then
echo "Correct password"
else
echo "Wrong password"
fi

no no not password... i am asking about pwd.. that is path of the file
#pwd
/htc/vivek
this path i need to store in a variable in script

 
vpath=`pwd`
1 Like

Hi,
I hope this is you are requesting.

$ pwd
/backup/shell
$ cat pwd.sh
#!/bin/sh
file=`pwd`
echo $file
$ sh pwd.sh
/backup/shell
$
1 Like

thanks amitranjansahu and thomasraj..... :slight_smile: thanks a lotamitranjansahu
Registered User

Hi.

You already have it, in $PWD.

If you want to take a copy of it, there's no need to "execute" pwd.

mypwd=$PWD
1 Like

oh thanks.. :slight_smile: this is simple than earlier.. i had tried mypwd=$pwd for the first time but it hadnt worked.. so its system defined i need to use upper case.. thanks.. :slight_smile: