Viewed k times. I'm reading an example bash shell script:! Redirect errors because this generates some if the archive does not exist. Then create a new compressed file. Improve this question.
JohnMerlino JohnMerlino 5, 11 11 gold badges 31 31 silver badges 37 37 bronze badges. Just a trick to avoid unnecessary output. I'm sure you could find more. Add a comment. Active Oldest Votes. Improve this answer. I also struggled with this. Idea from a coworker and from unix. Show 9 more comments. Walf 1 1 gold badge 11 11 silver badges 19 19 bronze badges. Thyag Thyag 4 4 silver badges 6 6 bronze badges. Superb, I've been struggling to understand this topic for ages, finally I know how to use it.
Explicit commands are the best way to explain and to memorize. Love this answer, thank you — Crescent Fresh. It could result in errors for a number of reasons, including: Inadequate permissions on the file s you're attempting to archive or on the file that you're attempting to write to Lack of disk space in order to create the archive.
Zibri Zibri 4 4 silver badges 9 9 bronze badges. Here is some handy information from the ABSG: "Redirection simply means capturing output from a file, command, program, or script and sending it as input to another file, command, program, or script.
These are typically the keyboard and screen, respectively, but any or all of them can be redirected to come from — or go to — a file or other program. STDIN is standard input, and is how the program receives interactive input. STDIN is usually assigned file descriptor 0. Redirects only STDOUT , because the file descriptor 2 is redirected to the file pointed to by file descriptor 1 which is not the file file yet when the statement is evaluated.
This can create surprising results if you expect a redirect to affect the entire pipeline. For example this command wrapped for legibility :. Instead, attach the error to the command you want to capture:. These examples write the output of the ls command into the file file. The default redirection descriptor is the standard output or 1 when none is specified. This command is equivalent to the previous examples with the standard output explicitly indicated:.
Note: the redirection is initialized by the executed shell and not by the executed command, therefore it is done before the command execution. File descriptors like 0 and 1 are pointers. We change what file descriptors point to with redirection. However, this form may be undesirable in production if shell compatibility is a concern as it conflicts with POSIX, introduces parsing ambiguity, and shells without this feature will misinterpret it:. Just move the redirection to the first command, i.
Or you can enclose everything in parenthesis: find Thank you, but this also does not work :S find. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses.
Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Linked Related Hot Network Questions.
0コメント