Whats the meaning


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Whats the meaning
# 1  
Old 03-16-2006
Whats the meaning

What the folowing statements means and whats the use of it ?

expr $db_name + 2 >/dev/null 2>&1

Thanks.
# 2  
Old 03-16-2006
This is my interpretation and very much open to correction,

this is finding the sum of a variable db_name and 2. And after this redirecting the output to dev/null.
2>&1 means if some error occurs then redirect the output to the same location as to which the normal output is redirected.

Gaurav
# 3  
Old 03-16-2006
Meaning

to /dev/null means where it redirects the output ...
whether its stored in the file or where ?

Error u mean to say in
expr command ...isnt it ?


Quote:
Originally Posted by gauravgoel
This is my interpretation and very much open to correction,

this is finding the sum of a variable db_name and 2. And after this redirecting the output to dev/null.
2>&1 means if some error occurs then redirect the output to the same location as to which the normal output is redirected.

Gaurav
# 4  
Old 03-16-2006
hey Gaurav,
pipinng output /dev/null is like wrting to a file but the contents is not stored in the file.I think its character device file.
cat /dev/null will display nothing inidicating nothing is stored in it.
# 5  
Old 03-16-2006
/dev/null is the bit bucket - a black hole for data. Everything goes in but never comes back out. Think of it as the perfect garbage bin for data.
# 6  
Old 03-16-2006
Hi,
this may help,

a unix program opens three files stdin, stdout and stderr when it strarts executing.
stdin has file descriptor as 0
stdout has 1, and
stderr has 2

unix commands read from stdin
the output goes to stdout
stderr is where unix commands write commands if they encounter errors

by default stdout and stderr goes to terminal.

so the command:
command > opfile 2>&1
means that messages for file descriptor 2 (stderr) goes to the same place as stdout (&1), i.e. is opfile in this case.

And in the command given by OP the stderr is redirected to /dev/null

Gaurav

Last edited by gauravgoel; 03-16-2006 at 08:52 AM..
# 7  
Old 03-16-2006
Thanks

Thanks Gaurav .......Thanks a lot


Quote:
Originally Posted by gauravgoel
Hi,
this may help,

a unix program opens three files stdin, stdout and stderr when it strarts executing.
stdin has file descriptor as 0
stdout has 1, and
stderr has 2

unix commands read from stdin
the output goes to stdout
stderr is where unix commands write commands if they encounter errors

by default stdout and stderr goes to terminal.

so the command:
command > opfile 2>&1
means that messages for file descriptor 2 (stderr) goes to the same place as stdout (&1), i.e. is opfile in this case.

And in the command given by OP the stderr is redirected to /dev/null

Gaurav
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Whats the meaning of set -e inside the script

Hi, I would like to ask about the meaning or purpose of set -e in the script bash, Does it mean if a wrong command in the script it will close or exit the script without continuation thats what happen if i set it in the terminal. Thanks in advance (3 Replies)
Discussion started by: jao_madn
3 Replies

2. Shell Programming and Scripting

##*_ - whats this?

Hi all, could you please tell me whats this stands ##*_ 0##*/ i knew this alone if some more is there please tell me that also. (3 Replies)
Discussion started by: Arunprasad
3 Replies

3. Shell Programming and Scripting

whats this NAME=${0##*/}

hi all, i found NAME=${0##*/} in a script. i given this coomand in my unix box(presently in ksh). echo ${0##*/} it returned ksh. the purpose of the above is to return the shell name or more than that. do you have any more information like this, please share with me. one more query... (7 Replies)
Discussion started by: Arunprasad
7 Replies

4. Shell Programming and Scripting

tell me whats wrong with this

#! /bin/bash USAGE=" | ] if then echo "$USAGE" exit 1 fi while getopts lb: OPTION do case $(OPTION)in a) echo Hi there! exit 2;; b) echo hello o) OARG=$OPTARG;; \?)echo "$USAGE" ;; exit 2;; esac done shift `expr... (1 Reply)
Discussion started by: nadman123
1 Replies

5. Shell Programming and Scripting

Whats the meaning of this code

Hi all, I am unable interpret this code ......... nohup $OPSSHLPATH/mkt_sas_load_cic.sh $db_name $process_id $loc_mm > $OPSLSTPATH/mkt_sas_load_cic.out & Thanks ....In advance (7 Replies)
Discussion started by: dhananjaysk
7 Replies

6. Shell Programming and Scripting

mail..whats this?

Can anyone explain meaning of this? It takes a lot of time to display mail when i type "mail" on prompt. -------------------------------------------------------- mail: Too many letters, overflowing letters concatenated -------------------------------------------------------- Regards... (1 Reply)
Discussion started by: abhijeetkul
1 Replies

7. What is on Your Mind?

Whats Behind Your Name?

Looking at the member list, there are alot of interesting names, some unique, some bizarre, and some that are just plain. How did you come by your name? Why did you choose your label? Me? Well, I wish I could change mine. I chose Google because thats how I stumbled upon this site. I wasn't sure... (66 Replies)
Discussion started by: google
66 Replies

8. Post Here to Contact Site Administrators and Moderators

Whats the go?

woofie, Your posts are being deleted because your use of profanity. I am close to changing your status to read only. In fact, if you argue with the mods again, I will ban you from these boards. Neo (1 Reply)
Discussion started by: Neo
1 Replies

9. Shell Programming and Scripting

Whats does this mean

Found this piece of code written in ksh. I have no ideas what do the stuff like ${SRF##*\.} do. SUFFIX=${SRF##*\.} if ; then SUFFIX="" fi I have encountered similar expressions in other programs also. Any pointers on where to learn more about these... (1 Reply)
Discussion started by: jyotipg
1 Replies
Login or Register to Ask a Question