From owner-svn-doc-all@FreeBSD.ORG Mon Feb 3 18:54:03 2014 Return-Path: Delivered-To: svn-doc-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D9DDA6F8; Mon, 3 Feb 2014 18:54:03 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B760D17BE; Mon, 3 Feb 2014 18:54:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s13Is3xi011811; Mon, 3 Feb 2014 18:54:03 GMT (envelope-from trhodes@svn.freebsd.org) Received: (from trhodes@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s13Is3vb011810; Mon, 3 Feb 2014 18:54:03 GMT (envelope-from trhodes@svn.freebsd.org) Message-Id: <201402031854.s13Is3vb011810@svn.freebsd.org> From: Tom Rhodes Date: Mon, 3 Feb 2014 18:54:03 +0000 (UTC) To: doc-committers@freebsd.org, svn-doc-all@freebsd.org, svn-doc-head@freebsd.org Subject: svn commit: r43736 - head/en_US.ISO8859-1/books/handbook/basics X-SVN-Group: doc-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-doc-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire doc trees \(except for " user" , " projects" , and " translations" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Feb 2014 18:54:03 -0000 Author: trhodes Date: Mon Feb 3 18:54:03 2014 New Revision: 43736 URL: http://svnweb.freebsd.org/changeset/doc/43736 Log: Add a small section on shell redirection and piping. Fix two sentences to not start with a lower case command. Reviewed by: bcr, wblock Modified: head/en_US.ISO8859-1/books/handbook/basics/chapter.xml Modified: head/en_US.ISO8859-1/books/handbook/basics/chapter.xml ============================================================================== --- head/en_US.ISO8859-1/books/handbook/basics/chapter.xml Mon Feb 3 17:35:21 2014 (r43735) +++ head/en_US.ISO8859-1/books/handbook/basics/chapter.xml Mon Feb 3 18:54:03 2014 (r43736) @@ -917,8 +917,8 @@ Other information: - &man.chfn.1; and &man.chsh.1; are links to - &man.chpass.1;, as are &man.ypchpass.1;, &man.ypchfn.1;, + The commands &man.chfn.1; and &man.chsh.1; are links + to &man.chpass.1;, as are &man.ypchpass.1;, &man.ypchfn.1;, and &man.ypchsh.1;. Since NIS support is automatic, specifying the yp before the command is not necessary. How to configure NIS is @@ -987,7 +987,7 @@ passwd: done pw - &man.pw.8; is a command line utility to create, remove, + The &man.pw.8; utility can create, remove, modify, and display users and groups. It functions as a front end to the system user and group files. &man.pw.8; has a very powerful set of command line options that make it @@ -3432,6 +3432,80 @@ Swap: 2048M Total, 2048M Free Then, rerun &man.chsh.1;. + + + + Advanced Shell Techniques + + + + + Tom + Rhodes + + Written by + + + + + The &unix; shell is not just a command interpreter, it + acts as a powerful tool which allows users to execute commands, + redirect their output, redirect their input and chain commands + together to improve the final command output. When this functionality + is mixed with built in commands, the user is provided with + an environment that can maximize efficiency. + + Shell redirection is the action of sending the output + or the input of a command into another command or into a + file. To capture the output of the &man.ls.1; command, for + example, into a file, simply redirect the output: + + &prompt.user; ls > directory_listing.txt + + The directory_listing.txt file will + now contain the directory contents. Some commands allow you + to read input in a similar one, such as &man.sort.1;. To sort + this listing, redirect the input: + + &prompt.user; sort < directory_listing.txt + + The input will be sorted and placed on the screen. To + redirect that input into another file, one could redirect + the output of &man.sort.1; by mixing the direction: + + &prompt.user; sort < directory_listing.txt > sorted.txt + + In all of the previous examples, the commands are performing + redirection using file descriptors. Every unix system has file + descriptors; however, here we will focus on three, so named as + Standard Input, Standard Output, and Standard Error. Each one + has a purpose, where input could be a keyboard or a mouse, + something that provides input. Output could be a screen or + paper in a printer for example. And error would be anything + that is used for diagnostic or error messages. All three + are considered I/O based file descriptors + and sometimes considered streams. + + Through the use of these descriptors, short named + stdin, stdout, and stderr, the shell allows output and + input to be passed around through various commands and + redirected to or from a file. Another method of redirection + is the pipe operator. + + The &unix; pipe operator, | allows the + output of one command to be directly passed, or directed + to another program. Basically a pipe will allow the + standard output of a command to be passed as standard + input to another command, for example: + + &prompt.user; cat directory_listing.txt | sort | less + + In that example, the contents of + directory_listing.txt will be sorted and + the output passed to &man.less.1;. This allows the user + to scroll through the output at their own pace and prevent + it from scrolling off the screen. +