![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
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 | ||
|
|
|
|||
|
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. |