Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-07-2002, 03:46 PM   #1
Registered: Jan 2002
Location: Burnaby British Columbia
Distribution: Redhat 7.1
Posts: 25

Rep: Reputation: 15
An easy one....

Hi Guys,

Doing a little bash scripting and came across a little mystery (well.. a mystery for me anyways). When I type
echo $PWD I get the current working directory echoed to console. How is $PWD being initialized with the current directory? Is it a variable that is maintained by the shell? And if so, where can I find reference to all of these shell variables?

Old 03-07-2002, 04:33 PM   #2
Registered: Oct 2001
Location: Atlanta, GA
Distribution: Red Hat 7.0
Posts: 45

Rep: Reputation: 15
You can get a list of all your current shell variables with the command:


The command:


means 'print working directory'. I'm not sure what throwing a $ in front of the command is actually doing, if it is doing anything at all.
Old 03-07-2002, 05:12 PM   #3
Registered: Jan 2002
Location: Burnaby British Columbia
Distribution: Redhat 7.1
Posts: 25

Original Poster
Rep: Reputation: 15

Thanks entm,

I also discovered that PWD is a special shell variable maintaned by bash to always be my current working directory.

In addition, the following are special variables:

PWD - always the current directory
RANDOM - a different number every time you access it
$$ - the current process id (of the script, not the user's shell)
PPID - the "parent process"s ID. (BUT NOT ALWAYS, FOR FUNCTIONS)
$? - exit status of last command run by the script
PS1 - your "prompt". "PS1='$PWD:> '" is interesting.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
easy connect not easy in suse greg collins Linux - Newbie 11 03-30-2006 08:31 PM
Easy urpmi ,no easy send mail. akihandyman Linux - General 2 12-27-2004 03:15 PM
Linux4RegularGuys - EASY FTP setup using vsftpd - READ THIS FOR EASY HELP DropHit Linux - Networking 4 11-25-2004 03:44 PM
Easy for most ... Please help.... kaz4u2dig Linux - Newbie 1 10-18-2004 10:46 PM
Here's an easy one... jhotchkiss Linux - Software 5 09-23-2003 12:53 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:26 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration