Sponsored Content
Full Discussion: pwd in a variable
Top Forums Shell Programming and Scripting pwd in a variable Post 302578620 by Scott on Friday 2nd of December 2011 03:54:10 AM
Old 12-02-2011
Hi.

You already have it, in $PWD.

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

Code:
mypwd=$PWD

This User Gave Thanks to Scott For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

PWD env variable for root

How do you get the $PWD env variable set for root? I know it's automatic for korn and other shells, but root uses /usr/bin/sh. (5 Replies)
Discussion started by: bcole23
5 Replies

2. 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

3. 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

4. UNIX for Dummies Questions & Answers

PWD env variable

Could you please tell me, which process / file is responsible for the setting of PWD env variable in Solaris Thanks (1 Reply)
Discussion started by: chaandana
1 Replies

5. 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

6. Shell Programming and Scripting

how to assign a pwd value to a variable

Hi, I want to assign a pwd value to a variable filepath=$pwd Thx in advance (4 Replies)
Discussion started by: vls1210
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. Red Hat

How to pass value of pwd as variable in SED to replace variable in a script file

Hi all, Hereby wish to have your advise for below: Main concept is I intend to get current directory of my script file. This script file will be copied to /etc/init.d. A string in this copy will be replaced with current directory value. Below is original script file: ... (6 Replies)
Discussion started by: cielle
6 Replies
PWD(1P) 						     POSIX Programmer's Manual							   PWD(1P)

PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond- ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. NAME
pwd - return working directory name SYNOPSIS
pwd [-L | -P ] DESCRIPTION
The pwd utility shall write to standard output an absolute pathname of the current working directory, which does not contain the filenames dot or dot-dot. OPTIONS
The pwd utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines. The following options shall be supported by the implementation: -L If the PWD environment variable contains an absolute pathname of the current directory that does not contain the filenames dot or dot-dot, pwd shall write this pathname to standard output. Otherwise, the -L option shall behave as the -P option. -P The absolute pathname written shall not contain filenames that, in the context of the pathname, refer to files of type symbolic link. If both -L and -P are specified, the last one shall apply. If neither -L nor -P is specified, the pwd utility shall behave as if -L had been specified. OPERANDS
None. STDIN
Not used. INPUT FILES
None. ENVIRONMENT VARIABLES
The following environment variables shall affect the execution of pwd: LANG Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of IEEE Std 1003.1-2001, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES . PWD If the -P option is in effect, this variable shall be set to an absolute pathname of the current working directory that does not contain any components that specify symbolic links, does not contain any components that are dot, and does not contain any compo- nents that are dot-dot. If an application sets or unsets the value of PWD, the behavior of pwd is unspecified. ASYNCHRONOUS EVENTS
Default. STDOUT
The pwd utility output is an absolute pathname of the current working directory: "%s ", <directory pathname> STDERR
The standard error shall be used only for diagnostic messages. OUTPUT FILES
None. EXTENDED DESCRIPTION
None. EXIT STATUS
The following exit values shall be returned: 0 Successful completion. >0 An error occurred. CONSEQUENCES OF ERRORS
If an error is detected, output shall not be written to standard output, a diagnostic message shall be written to standard error, and the exit status is not zero. The following sections are informative. APPLICATION USAGE
None. EXAMPLES
None. RATIONALE
Some implementations have historically provided pwd as a shell special built-in command. In most utilities, if an error occurs, partial output may be written to standard output. This does not happen in historical implementations of pwd. Because pwd is frequently used in historical shell scripts without checking the exit status, it is important that the historical behavior is required here; therefore, the CONSEQUENCES OF ERRORS section specifically disallows any partial output being written to stan- dard output. FUTURE DIRECTIONS
None. SEE ALSO
cd, the System Interfaces volume of IEEE Std 1003.1-2001, getcwd() COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 PWD(1P)
All times are GMT -4. The time now is 11:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy