Home Tutorials IT Jobs Source Codes Certifications Discussion Forum
  Linux Tutorial
Linux Introduction
Unix
Linus and Linux
What Kernel Is?
Linux Commands
Linux Shell
Root and Other Users
Virtual Consoles
Logoff and Shutdown
The Command Prompt
Wildcards
Command History
Aliases
Redirection
Pipelines
Stopping a Program
Environment Variables
Exit Status
Linux File System
Linux File Names
Linux Directories
Directory Terminology
Navigating the File System
Listing Linux Files
Linux Downloads
Recommended Books
   IT Jobs
Software Jobs
Networking Jobs
   Model Question Papers
BE Computer Science
MCA
BCA
Others
 
   

Pipes

To see who is on the system with you, type

% who

One method to get a sorted list of names is to type,

% who > names.txt
% sort < names.txt

This is a bit slow and you have to remember to remove the temporary file called names when you have finished. What you really want to do is connect the output of the who command directly to the input of the sort command. This is exactly what pipes do. The symbol for a pipe is the vertical bar |

For example, typing

% who | sort

will give the same result as above, but quicker and cleaner.

To find out how many users are logged on, type

% who | wc -l

Example

Using pipes, display all lines of list1 and list2 containing the letter 'p', and sort the result.

% cat list1 list2 | grep p | sort

<< Previous | Next >>

Home  |  About us  | Privacy  |  Disclaimer  |  Contact us |  Advertise with us | Our Link Partners
All Rights Reserved 2009, CodeTeller.com