what is the meaning of the following redirection


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users what is the meaning of the following redirection
# 1  
Old 09-05-2009
what is the meaning of the following redirection

Hello bash experts.,

I was doing some experimentations to better understand the following redirection.,

Code:
$Output = `sh -c \"$Cmd 2>&1 1>&2\"`;

It is actually the line used in one of the perl program, but the technique i am trying to understand is related to shell scripting.

So is there any better explanation or reference where i can understand, which will do what and what is the flow in which it get executed ?! What happens to the output, and what will happen to the stderror ?
# 2  
Old 09-05-2009
After playing around with a perl program I whipped up that prints to STDERR and STDOUT I found doing: 2>&1has the exact same end result as 2>&1 1>&2. Maybe one of the shell scripting gurus here can correct me if I am wrong.

Last edited by ilikecows; 09-05-2009 at 12:48 PM.. Reason: tested answer
# 3  
Old 09-05-2009
Code:
command 2>&1 1>&2

Imho "1>&2" is indeed meaningless here, because in this case "2>&1" already redirected stderror(2) to whatever stdout(1) was pointing to, so they are both pointing to the same thing.

Last edited by Scrutinizer; 09-07-2009 at 11:02 AM.. Reason: It said stdin instead of stdout
# 4  
Old 09-06-2009
Sorry for being critical Scrutinizer but the 1 filehandle is STDOUT.

Reference: Solaris 10u7 bash man page
# 5  
Old 09-06-2009
Deleted... misread myself.

Last edited by Vi-Curious; 09-06-2009 at 10:17 PM.. Reason: Delete post
# 6  
Old 09-07-2009
Quote:
Originally Posted by ilikecows
Sorry for being critical Scrutinizer but the 1 filehandle is STDOUT.

Reference: Solaris 10u7 bash man page
You are right of course. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Meaning of $1^

Hello everyone, I'm looking for the meaning of this expression, as I don't understand it quite clearly : $1^ What do you think it could be? I thought either: - match lines starting with argument 1 but it should be ^$1 - turn line around : word becomes drow Thanks in advance for your... (4 Replies)
Discussion started by: bibelo
4 Replies

2. Shell Programming and Scripting

Meaning

Please let me know the meaning for the below statements in shell scripting. 1) exit -99 -------------------------------- 2) set prgdir = `pwd` set runFlag = runFlag:FALSE ------------------------------------- 3) if (-f $prgdir/maillst.eml) then set distEmail = `cat $prgdir/maillst.eml`... (1 Reply)
Discussion started by: lg123
1 Replies

3. UNIX for Dummies Questions & Answers

meaning of <<!

Hi all, I wanna know the meaning of the last word "<<! " sudo su - user <<! please help on this !!!! (1 Reply)
Discussion started by: sudharson
1 Replies

4. Shell Programming and Scripting

^$$ meaning

Hi , Can anyone please let me know whta the follwoing piece of code for ScriptName=${0##*/} if pgrep -f "$ScriptName" | grep -v "^$$\$" ; then echo `date`": Sctipt $ScritName is already runnig" exit fi Thnx a lot in advance Please use code tags when posting data and code... (8 Replies)
Discussion started by: Pratik4891
8 Replies

5. Shell Programming and Scripting

meaning of !*

can someone please tell what !* means in shell syntax. Regards, (3 Replies)
Discussion started by: busyboy
3 Replies

6. Shell Programming and Scripting

Output redirection meaning

Hi, Can anyone please explain the details of the code below :- ls /etc/*.txt > /dev/null 2>&1 (6 Replies)
Discussion started by: angshuman_ag
6 Replies

7. Shell Programming and Scripting

What is the meaning of $_

Hi, Can somebody tell the usage of "$_" cd $_ ? and ls $_ ? (4 Replies)
Discussion started by: giri_luck
4 Replies

8. UNIX for Dummies Questions & Answers

what the meaning of #*

can some one please tell the meaning of the second statement i.e n=${m#*=} i couldnt get the meaning of the #*= 1.) m="mohit=/c/main/issue" echo $m result ----------- mohit=/c/main/issue 2.) n=${m#*=} echo $n RESULT ------- /c/main/issue (1 Reply)
Discussion started by: narang.mohit
1 Replies

9. UNIX for Dummies Questions & Answers

Use and meaning of $*

Can someone explain the use and meaning of "$*" expression. (2 Replies)
Discussion started by: sinpeak
2 Replies

10. Shell Programming and Scripting

what is the meaning here?

#!/bin/sh $ORACLE_HOME/bin/sqlplus -S $orauserid/$orapasswd@$oradb << _TMP alter session set nls_date_format = 'YYYYMMDD HH24:MI'; set linesize 100 set pagesize 400 ok the above is part of a script..i just wanna know what does sqlplus -S means?? as in why we need to insert the -S behind? (2 Replies)
Discussion started by: forevercalz
2 Replies
Login or Register to Ask a Question