The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Piping Question mtobin1987 High Level Programming 2 04-25-2008 08:24 PM
Piping to ex from a script mph Shell Programming and Scripting 2 10-11-2007 12:54 PM
piping lnatz Shell Programming and Scripting 1 07-13-2006 11:30 PM
Help (Piping ls, tr, cut) scan Shell Programming and Scripting 2 02-11-2006 04:40 AM
Tar and gunzip piping madyodacolon Shell Programming and Scripting 2 05-11-2004 07:27 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-25-2002
Registered User
 

Join Date: Feb 2002
Location: Portugal
Posts: 22
Stumble this Post!
Smile redirecting/piping

i want to fully undertand redirecting/piping. i know most of the basic stuff, like ls|less or cat file|grep hello etc etc. but there are a somethings like find / -name file 2>/dev/null. what's is the 2? i know it redirects the errors (at least Permission denied ones) to /dev/null (the unix blackhole).

can someone tell what the 2 is for, up there? and... any site i can check out to understand complex piping?

thx in advance
Forum Sponsor
  #2 (permalink)  
Old 03-25-2002
thehoghunter
Guest
 

Posts: n/a
Stumble this Post!
Straight from the man page for ksh:

Input/Output
Before a command is executed, its input and output may be
redirected using a special notation interpreted by the
shell. The following may appear anywhere in a simple-
command or may precede or follow a command and are not
passed on to the invoked command. Command and parameter
substitution occur before word or digit is used except as
noted below. File name generation occurs only if the pat-
tern matches a single file, and blank interpretation is not
performed.

...

If one of the above is preceded by a digit, then the file
descriptor number referred to is that specified by the digit
(instead of the default 0 or 1). For example:

... 2>&1

means file descriptor 2 is to be opened for writing as a
duplicate of file descriptor 1.

....
The order in which redirections are specified is signifi-
cant. The shell evaluates each redirection in terms of the
(file descriptor, file) association at the time of evalua-
tion. For example:

... 1>fname 2>&1

first associates file descriptor 1 with file fname. It then
associates file descriptor 2 with the file associated with
file descriptor 1 (that is fname). If the order of redirec-
tions were reversed, file descriptor 2 would be associated
with the terminal (assuming file descriptor 1 had been) and
then file descriptor 1 would be associated with file fname.

If a command is followed by & and job control is not active,
then the default standard input for the command is the empty
file /dev/null. Otherwise, the environment for the execu-
tion of a command contains the file descriptors of the
invoking shell as modified by input/output specifications.
  #4 (permalink)  
Old 03-25-2002
Registered User
 

Join Date: Feb 2002
Location: Portugal
Posts: 22
Stumble this Post!
thx for the trouble of copying/pasting the man here and for giving me the URLs.
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:26 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0