If statement in my prompt?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers If statement in my prompt?
# 1  
Old 11-08-2010
If statement in my prompt?

Anyone know how I can do a simple if statement in my prompt? As it is now I run a few commands to customize my prompt using command substitution. What I would prefer is if I could change the color dependent on the results.

So `command` > output > if = 'x' then color=blue else color=red

That way I can make certain problems stand out more and draw my attention to them.

As it is I have a ridiculously complicated prompt that runs numerous commands and generate a 2 line prompt filled with useful nuggets of info.. sometimes I miss something.
# 2  
Old 11-08-2010
Something like this?
Code:
if [ `command` = "x" ]; then ....; fi

# 3  
Old 11-08-2010
For an example of Franklin52's suggestion have a look at this post in this thread:https://www.unix.com/showthread.php?t=146853, 2 weeks ago.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies

2. Solaris

Unable to move from rsc prompt to ok prompt

Hi, on sunfire v890 unable to move from rsc prompt to ok prompt, i have executed the command break. (9 Replies)
Discussion started by: manoj.solaris
9 Replies

3. UNIX for Dummies Questions & Answers

How to Change the % prompt to - prompt in UNIX?

how to Change the % prompt to - prompt in unix :wall: ---------- Post updated at 07:40 AM ---------- Previous update was at 07:38 AM ---------- How To display the last modification time of any file in unix ---------- Post updated at 07:40 AM ---------- Previous update was at 07:40 AM... (2 Replies)
Discussion started by: manjiri sawant
2 Replies

4. Solaris

No prompt!

We have a Solaris 10 machine. Today a weird issue happened. After login remotely via ssh, the motd appeared BUT there was no prompt! The prompt only appears after pressing Ctrl+d or Ctrl+c. Strange behaviour. I have checked /etc/profile and own user .profile, there is no anamoly. ... (11 Replies)
Discussion started by: sundar63
11 Replies

5. Solaris

ok prompt

There is a number before the ok prompt in OBP between brackets {}. It is 0 most of the time but sometimes it is different number {9} ok or {0} ok What does this number mean and how it gets changed? (3 Replies)
Discussion started by: StarSol
3 Replies

6. Shell Programming and Scripting

How is use sselect statement o/p in insert statement.

Hi All, I am using Unix ksh script. I need to insert values to a table using the o/p from a slelect statement. Can anybody Help! My script looks like tihs. ---`sqlplus -s username/password@SID << EOF set heading off set feedback off set pages 0 insert into ${TB_NAME}_D... (2 Replies)
Discussion started by: nkosaraju
2 Replies

7. Shell Programming and Scripting

If statement - How to write a null statement

In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands. How do I write the "do nothing" statement in the following example? Example: if (( "$x"="1" && "$y"="a" && "$z"="happy" )) then do nothing else command command fi... (3 Replies)
Discussion started by: april
3 Replies

8. Shell Programming and Scripting

How to a prompt a particular value???

Hi i am working with clearcase in my UNIX machine... Accidentally some had ran a script to check out all files in the machine.... Now i am actually trying to uncheck out all those files and had written a script for it.... The problem is that when ever i am trying to uncheck out the files, its... (2 Replies)
Discussion started by: grajesh_955
2 Replies

9. Solaris

OK prompt

Here is a silly question: I have a Sun 220R and I need to get to the OK prompt. I can't hook up a monitor and keyboard to it. Its on a KVM right now and I also have a console connected to it. I can use PuTTY to get to the console and then connect to the 220R from there. How can I get to the... (3 Replies)
Discussion started by: hshapiro
3 Replies

10. Solaris

Can't get ok prompt

Hi, I'm attempting to reinstall a damaged installation of Solaris 9 (on a SunFire). Connected via serial from a PC. Can't get to the "ok" prompt to launch install from CD. Ctrl+break acknowledges my request for a break, but no prompt. "#." gets me an "sc>" prompt, with several options, but... (3 Replies)
Discussion started by: shonenfan
3 Replies
Login or Register to Ask a Question