Sponsored Content
Full Discussion: $pwd
Top Forums UNIX for Beginners Questions & Answers $pwd Post 302974330 by bakunin on Saturday 28th of May 2016 08:04:07 AM
Old 05-28-2016
Quote:
Originally Posted by abbya
Hi all,when I cd to an environment variable "cd $MYDIR, if I type pwd, I don't the path to the environment variable dir I cd to.
But what else, instead?

Your request amounts to something like when i add 1 to 1 i don't want the result to be 2.

When you set an environment variable "MYDIR" to some value, say, "/some/where" and you do a cd $MYDIR you do - effectively - a cd /some/where.

If you now issue the command pwd, it will tell you the current directory you are in. In fact, this - to tell you the current directory you are in - is the very purpose of the command pwd. And because you just changed to /some/where before this current directory will invariably be /some/where.

Just in case you meant the (enviroment variable) $PWD (not "$pwd" - UNIX is case sensitive): this is a variable automatically maintained by many shells (ksh and bash among them) to always point to the same (current) directory, the command pwd is displaying. For this, the same goes as i already said about the command. If you go to a certain location you are there - and because "location" is where you are, regardless of where this is, it will be your location and your location will be where you are.

And, by the way, i would appreciate if you could come up with more telling thread titles. Maybe i am extra slow, but i couldn't glean any meaning from "$pwd".

I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

help on PWD

Hi, We all know that pwd (or echo $PWD) gives us the present working dir as output.... but my doubt is that I'ld like to know how to get the present working folder - I mean - name of the current folder alone.. using pwd command I get the full folder name (right from root path)... I need to know... (2 Replies)
Discussion started by: mohanprabu
2 Replies

2. UNIX for Dummies Questions & Answers

pwd

Home directory mounted on one local system as /home/username, same directory mounted on a remote system as /home/engr/username. How to use command to use remote host pwd. For example rsh <remote host> ls -l ~pwd (2 Replies)
Discussion started by: bugsandbunny
2 Replies

3. UNIX for Advanced & Expert Users

echo ${PWD#${PWD%/*/*}/}

Can anyone explain this in detail ... echo ${PWD#${PWD%/*/*}/} Thanks in Advance (1 Reply)
Discussion started by: sakthi.abdullah
1 Replies

4. UNIX for Advanced & Expert Users

console '# ' with {PWD} ??

Hi people... i recently installed AIX 5.3 on a server... but now when i login with root it only shows '# ' without the location where i am... for example: if im in /usr/local it continues to show only '# ' and i want to see the path like 'root@server:/usr/local#' someone can help me? ... (2 Replies)
Discussion started by: gfca
2 Replies

5. UNIX for Dummies Questions & Answers

how to connect to /etc/pwd

i've been searching the way to connect to pwd.db file located in /etc/ directory.. since i'm not the root and only one of the users of the server, i need to connect to the database so that i can make a login page for all users of the server.. the file is readable by all users and the permission... (1 Reply)
Discussion started by: meggae
1 Replies

6. UNIX for Dummies Questions & Answers

PWD COMMAND

Hi, Can you tell me if there is a command such as pwd which does not give me the absolute NFS pathname i.e. it starts with .autofs? At the moment on the unix when I use the 'pwd' command it always gives me the nfs pathname rather thanthe local pathname of which is what i want, is there an... (4 Replies)
Discussion started by: cyberfrog
4 Replies

7. AIX

sync samba pwd with aix5.3 pwd

currently, my samba login works just fine. i want my clients to use aix5.3 account to login to samba so they don't have to change samba pwd and aix pwd. i googled, and vi /usr/lib/smb.conf per some of knowledge base, but i could not get to work. aix5.3 and samba 3.0.24.0 thanks in advace..... (2 Replies)
Discussion started by: tjmannonline
2 Replies

8. UNIX for Dummies Questions & Answers

pwd help

Dear users, One more question, In unix when i use pwd the following I get: pwd /Users/username/src/directory name Is there a way to get the out put like this in which the if there is a space in the directory eg directory name it should show as directory\ name:... (2 Replies)
Discussion started by: kevincobain2000
2 Replies

9. UNIX for Dummies Questions & Answers

$PWD vs `pwd`

Hi, can anyone expalin the real importance of PWD as a variable. However pwd command and $PWD is going to give the same result, then why do we have 2 different things. Please give some example which illustrates the difference between both. Thanks (9 Replies)
Discussion started by: pandeesh
9 Replies

10. Shell Programming and Scripting

Help with 'pwd' command

Dear all, I am trying to use 'pwd' command in following way. current_directory == /dirA/dirB/test/dirC if ; then do this fi I am not sure how to pass this in command way. Please help! thanking you, emily (10 Replies)
Discussion started by: emily
10 Replies
PWD(1)							    BSD General Commands Manual 						    PWD(1)

NAME
pwd -- return working directory name SYNOPSIS
pwd [-L | -P] DESCRIPTION
The pwd utility writes the absolute pathname of the current working directory to the standard output. Some shells may provide a builtin pwd command which is similar or identical to this utility. Consult the builtin(1) manual page. The options are as follows: -L Display the logical current working directory. -P Display the physical current working directory (all symbolic links resolved). If no options are specified, the -L option is assumed. ENVIRONMENT
Environment variables used by pwd: PWD Logical current working directory. EXIT STATUS
The pwd utility exits 0 on success, and >0 if an error occurs. SEE ALSO
builtin(1), cd(1), csh(1), sh(1), getcwd(3) STANDARDS
The pwd utility conforms to IEEE Std 1003.1-2001 (``POSIX.1''). BUGS
In csh(1) the command dirs is always faster because it is built into that shell. However, it can give a different answer in the rare case that the current directory or a containing directory was moved after the shell descended into it. The -L option does not work unless the PWD environment variable is exported by the shell. BSD
April 12, 2003 BSD
All times are GMT -4. The time now is 06:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy