The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
understanding the prstat log dipashre SUN Solaris 9 01-29-2009 04:37 PM
Understanding cut krishmaths Shell Programming and Scripting 3 01-22-2009 07:46 AM
Understanding ZFS: Compression iBot Solaris BigAdmin RSS 0 11-19-2008 05:40 PM
need further understanding of init.d jigarlakhani UNIX for Advanced & Expert Users 1 09-20-2002 03:11 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-04-2009
mojoman mojoman is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 179
Understanding 2>&1

Hi,

I have this line in a script:

if mt -f /dev/nst0 rewind > /tmp/status_nst0.log 2>&1 ; then [more code]


What does the 2>&1 mean? I think the line is saying that after rewinding the device if the log file does not exist then execute the code but I do not understand the contribution of the 2>&1.

Thanks!
  #2 (permalink)  
Old 03-04-2009
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink

It will redirect Std-Error to Std-Output

In other words, it will send any error messages to whatever you have currently defined for output. Normal output would be your screen, but you can set this so output is going to a file.

Code:
ls -l >file1
will send your file listing to file1, error mesages will come to the screen

Code:
ls -l 2>&1 >file2
will send the file listing and errors to file2
  #3 (permalink)  
Old 03-04-2009
ce9888 ce9888 is offline
Registered User
  
 

Join Date: Aug 2008
Location: Montreal, Qc, CA
Posts: 98
1 is std output
2 is std error

2 >&1 means redirect std error to std output wihich is /tmp/status_nst0.log in the exemple you posted. Its in no way in relation with your device.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:56 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0