LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 10-16-2010, 07:46 AM   #1
xiaoqing87316
LQ Newbie
 
Registered: Mar 2010
Posts: 5

Rep: Reputation: 0
Question shell script /etc/profile


here is part of my /etc/profile file

for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "$PS1" ]; then
. $i
else
. $i >/dev/null 2>&1
fi
fi
done

my qusetion is what does the line " if [ "$PS1" ]; " mean.I never see this form before.many thanks!
 
Old 10-16-2010, 08:00 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

That line checks if a prompt is set or not.

PS1 is your main prompt.

Your prompt is normally set in /etc/profile and/or /etc/bashrc (although you can redefine it in your personal bash files. ~/.bashrc and/or ~/.bash_profile).

Hope this helps.
 
1 members found this post helpful.
Old 10-16-2010, 08:05 AM   #3
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS6
Posts: 267

Rep: Reputation: 57
Usually your bashrc has:
Code:
 
# are we an interactive shell?
if [ "$PS1" ]; then
If so, it means you are in an interactive shell.

Last edited by david1941; 10-16-2010 at 08:05 AM. Reason: fix code tag
 
1 members found this post helpful.
Old 10-16-2010, 08:16 AM   #4
xiaoqing87316
LQ Newbie
 
Registered: Mar 2010
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks for your help! with your words,I've made a big progress in my shell script learning .
 
Old 10-16-2010, 11:56 AM   #5
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,692

Rep: Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987
Please mark as SOLVED if you have your solution.
 
  


Reply

Tags
shell scripting


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
Executing a Shell script with 654 permissions inside another shell script. changusee2k Linux - Newbie 2 06-07-2011 08:58 PM
pass variable from one shell script into another shell script xskycamefalling Programming 9 10-03-2009 02:45 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 06:32 PM
shell script to find user(s) profile j-me Programming 2 01-31-2003 12:16 PM


All times are GMT -5. The time now is 03:56 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration