LINFO

Vertical Bar Character Definition


The vertical bar character is a character that has the form of a vertical line. It is located over the backslash character on U.S. keyboards.

The vertical bar character is used to represent a pipe in commands in Linux and other Unix-like operating systems. A pipe is a form of redirection that is used to send the output of one program to another program for further processing.

In the following example, the contents of file1 are read by the cat command and then piped to the wc command, which counts the number of lines, words and characters in it:

cat file1 | wc

Another common use for the vertical bar character in computer software, such as in regular expressions and when indicating the syntax of a command, is to indicate or, that is, to separate alterative possibilities.

A regular expression is a string (i.e., sequence of characters) that is used to describe or match some set of strings. Regular expressions are commonly used in text editors and programming languages for searching for and manipulating text. For example, (a-z|0-9) would represent to any lower case letter from a to z or any numeral from zero to nine. The hyphens are used to represent ranges.




Created August 5, 2007.
Copyright © 2007 The Linux Information Project. All Rights Reserved.