LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-07-2002, 02:46 PM   #1
Sonny
Newbie
 
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?

Sonny.
 
Old 03-07-2002, 03:33 PM   #2
entm
Member
 
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:

env

The command:

pwd

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, 04:12 PM   #3
Sonny
Newbie
 
Registered: Jan 2002
Location: Burnaby British Columbia
Distribution: Redhat 7.1
Posts: 25

Original Poster
Rep: Reputation: 15
aaahhh...

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.


Sonny.
 
  


Reply



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 07:31 PM
Easy urpmi ,no easy send mail. akihandyman Linux - General 2 12-27-2004 02:15 PM
Linux4RegularGuys - EASY FTP setup using vsftpd - READ THIS FOR EASY HELP DropHit Linux - Networking 4 11-25-2004 02:44 PM
Easy for most ... Please help.... kaz4u2dig Linux - Newbie 1 10-18-2004 09:46 PM
Here's an easy one... jhotchkiss Linux - Software 5 09-23-2003 11:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:02 PM.

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