q2K BHP
Black History Portal
THE BHP WIRE —
HIDDEN TRUTHS
What's New!
THE JOURNEY THROUGH TIME

Explore Black History

Explore the people, places, events, achievements, struggles and stories that shaped our journey.

✊🏾

Civil Rights

Movements, leaders, victories and the continuing fight for equality.

⚙️

Black Inventors

Innovation, patents, science, technology and world-changing contributions.

🏆

Sports

Pioneers, champions, Negro Leagues, records, activism and excellence.

♟️

People

Meet the people whose lives, choices and achievements shaped the journey.

📍

Places

Black towns, communities, institutions and places where history happened.

📜

Events

Moments that changed communities, movements, institutions and the nation.

Enter a person, place, event, or topic.
MY'STORY

The MOVE Fire

This is a personal recollection on the Move fire on May 13, 1985 Philadelphia police fired thousands of rounds at the MOVE house, city officials approved dropping an explosive device on the roof, the resulting fire was allowed to burn, 11 people—including five children—died, and 61 homes were destroyed. Philadelphia City Council later called it a “brutal attack carried out by the City of Philadelphia on its own citizens” and acknowledged that no individual faced criminal consequences for the bombing. One timeline correction worth preserving for the BHP record: the major previous MOVE-police confrontation was August 8, 1978, about seven years before the bombing, not a year or two earlier. Officer James Ramp was killed, other police and firefighters were wounded, nine MOVE members were later convicted, and television cameras recorded police beating Delbert Africa during his arrest. The 1985 MOVE Commission later specifically criticized city planners for failing to adequately use lessons from that 1978 confrontation. And that actually strengthens the point you’re making: 1985 did not happen without precedent or institutional memory. There had already been a deadly confrontation with MOVE, years of conflict, negotiations and police involvement before Osage Avenue.

MORE →
BLACK FACTS
The Truths They Never Taught You...

Ruler of the Mali Empire in the 14th century

Mansa Musa was the ruler of the Mali Empire in West Africa. Details recorded here should be sourced; unknown information is left blank.

MORE →
BHP gathered finds from its connected research sources. Showing the 4 strongest Black History matches.
← BACK TO RESULTS
Wikipedia

Redirection (computing)

The standard streams for input, output, and error

In computing, redirection is a form of interprocess communication, and is a function common to most command-line interpreters, including the various Unix shells that can redirect standard streams to user-specified locations. The concept of redirection is quite old, dating back to the earliest operating systems (OS).[citation needed] A discussion of the design goals for redirection can be found already in the 1971 description of the input-output subsystem of the Multics OS.[1] However, prior to the introduction of UNIX OS with its "pipes", redirection in operating systems was hard or even impossible to do.[2]

In Unix-like operating systems, programs do redirection with the dup2(2) system call, or its less-flexible but higher-level stdio analogues, freopen(3) and popen(3).[3]

Redirecting standard input and standard output

[edit]

Redirection is usually implemented by placing certain characters between commands.

Basic

[edit]

Typically, the syntax of these characters is as follows, using < to redirect input, and > to redirect output. command > file1 executes command, placing the output in file1, as opposed to displaying it at the terminal, which is the usual destination for standard output. This will clobber any existing data in file1.

Using command < file1 executes command, with file1 as the source of input, as opposed to the keyboard, which is the usual source for standard input.

command < infile > outfile combines the two capabilities: command reads from infile and writes to outfile

Variants

[edit]

To append output to the end of the file, rather than clobbering it, the >> operator is used: command1 >> file1.

To read from a stream literal (an inline file, passed to the standard input), one can use a here document, using the << operator:

$ tr a-z A-Z << END_TEXT
> one two three
> uno dos tres
> END_TEXT
ONE TWO THREE
UNO DOS TRES

To read from a string, one can use a here string, using the <<< operator: tr a-z A-Z <<< "one two three", or:

$ NUMBERS="one two three"
$ tr a-z A-Z <<< "$NUMBERS"
ONE TWO THREE

Piping

[edit]
A pipeline of three programs run on a text terminal

Programs can be run together such that one program reads the output from another with no need for an explicit intermediate file. command1 | command2 executes command1, using its output as the input for command2 (commonly called piping, with the "|" character being known as the "pipe").

The two programs performing the commands may run in parallel with the only storage space being working buffers (Linux allows up to 64K for each buffer) plus whatever work space each command's processing requires. For example, a "sort" command is unable to produce any output until all input records have been read, as the very last record received just might turn out to be first in sorted order. Dr. Alexia Massalin's experimental operating system, Synthesis, would adjust the priority of each task as they ran according to the fullness of their input and output buffers.[4]

This produces the same end result as using two redirects and a temporary file, as in:

$ command1 > tempfile
$ command2 < tempfile
$ rm tempfile

But here, command2 does not start executing until command1 has finished, and a sufficiently large scratch file is required to hold the intermediate results as well as whatever work space each task required. As an example, although DOS allows the "pipe" syntax, it employs this second approach. Thus, suppose some long-running program "Worker" produces various messages as it works, and that a second program, TimeStamp copies each record from stdin to stdout, prefixed by the system's date and time when the record is received. A sequence such as Worker | TimeStamp > LogFile.txt would produce timestamps only when Worker had finished, merely showing how swiftly its output file could be read and written.

A good example for command piping is combining echo with another command to achieve something interactive in a non-interactive shell, e.g. echo -e 'user\npass' | ftp localhost. This runs the ftp client with input user, press return, then pass.

In casual use, the initial step of a pipeline is often cat or echo, reading from a file or string. This can often be replaced by input indirection or a here string, and use of cat and piping rather than input redirection is known as useless use of cat. For example, the following commands:

$ cat infile | command
$ echo $string | command
$ echo -e 'user\npass' | ftp localhost

can be replaced by:

$ command < infile
$ command <<< $string
$ ftp localhost <<< $'user\npass'

As echo is often a shell-internal command, its use is not as criticized as cat, which is an external command.

Redirecting to and from the standard file handles

[edit]

In Unix shells derived from the original Bourne shell, the first two actions can be further modified by placing a number (the file descriptor) immediately before the character; this will affect which stream is used for the redirection.[5] The Unix standard I/O streams are:[6]

Handle Name Description
0 stdin Standard input
1 stdout Standard output
2 stderr Standard error

For example, command 2> file1 executes command, directing the standard error stream to file1.

In shells derived from csh (the C shell), the syntax instead appends the & (ampersand) character to the redirect characters, thus achieving a similar result. The reason for this is to distinguish between a file named '1' and stdout, i.e. cat file 2>1 vs cat file 2>&1. In the first case, stderr is redirected to a file named '1' and in the second, stderr is redirected to stdout.

Another useful capability is to redirect one standard file handle to another. The most popular variation is to merge standard error into standard output so error messages can be processed together with (or alternately to) the usual output. For example, find / -name .profile > results 2>&1 will try to find all files named .profile. Executed without redirection, it will output hits to stdout and errors (e.g. for lack of privilege to traverse protected directories) to stderr. If standard output is directed to file results, error messages appear on the console. To see both hits and error messages in file results, merge stderr (handle 2) into stdout (handle 1) using 2>&1.

If the merged output is to be piped into another program, the file merge sequence 2>&1 must precede the pipe symbol, thus, find / -name .profile 2>&1 | less

A simplified but non-POSIX conforming form of the command, command > file 2>&1 is (not available in Bourne Shell prior to version 4, final release, or in the standard shell Debian Almquist shell used in Debian/Ubuntu): command &>file or command >&file.

It is possible to use 2>&1 before ">" but the result is commonly misunderstood. The rule is that any redirection sets the handle to the output stream independently. So "2>&1" sets handle 2 to whatever handle 1 points to, which at that point usually is stdout. Then ">" redirects handle 1 to something else, e.g. a file, but it does not change handle 2, which still points to stdout.

In the following example, standard output is written to file, but errors are redirected from stderr to stdout, i.e. sent to the screen: command 2>&1 > file.

To write both errors and standard output to file, the order should be reversed. Standard output would first be redirected to the file, then stderr would additionally be redirected to the stdout handle that has already been changed to point at the file: command > file 2>&1.

Chained pipelines

[edit]

The redirection and piping tokens can be chained together to create complex commands. For example, sort infile | uniq -c | sort -n > outfile sorts the lines of infile in lexicographical order, writes unique lines prefixed by the number of occurrences, sorts the resultant output numerically, and places the final output in outfile.[7] This type of construction is used very commonly in shell scripts and batch files.

Redirect to multiple outputs

[edit]

The standard command tee can redirect output from a command to several destinations:ls -lrt | tee xyz. This directs the file list output to both standard output and the file xyz.

See also

[edit]

References

[edit]
  1. ^ Feiertag & Organick 1972.
  2. ^ Kernighan & Morgan 1982, p. 780, Input/output redirection.
  3. ^ The GNU C Library Reference Manual for version 2.38 gnu.org
  4. ^ "KHB: Synthesis: An Efficient Implementation of Fundamental Operating Systems Services". lwn.net.
  5. ^ Nozaki, Roberto (April 21, 2022). "How to redirect shell command output". www.redhat.com.
  6. ^ "Redirections (Bash Reference Manual)". www.gnu.org.
  7. ^ "Piping and Redirecting Output in the Linux Terminal". Linux.org.

Sources

[edit]
[edit]

Source: Wikipedia. Article content is retrieved live through the MediaWiki API.

Wikipedia

Redirection (computing)

In computing, redirection is a form of interprocess communication, and is a function common to most command-line interpreters, including the various Unix shells that can redirect standard streams to user-specified locations. The concept of redirection is quite old, dating back to the earliest operating systems (OS). A discussion of the design goals for redirection can be found already in the 1971 description of the input-output subsystem of the Multics OS. However, prior to the introduction of UNIX OS with its "pipes", redirection in operating systems was hard or even impossible to do. In Unix-like operating systems, programs do redirection with the dup2(2) system call, or its less-flexible but higher-level stdio analogues, freopen(3) and popen(3).

MORE →
No preview image
Wikipedia

Folder redirection

In computing, and specifically in the context of Microsoft Windows, folder redirection refers to automatically re-routing to or from standard folders to use storage elsewhere on a network. It is often used in an office network environment to ensure that users do not store data locally when a network device is the preferred storage location. Folder Redirection allows saving data regardless of storage location and separates user data from profile data decreasing the time required to log on. Other advantages include: Data is stored on a server where it can be backed up If the same redirection is applied to multiple users, all data is stored in the one location Allows for sharing of data between users directly from the server rather than creating shares on individual workstations Allows system administrators to spend less on workstation hard drives, and more on file server hard drives If all user folders are redirected and caching is disabled, no files are stored on the workstations and thus data is better protected from theft Under Microsoft Windows, the redirection is often performed by Group Policy, when used in an Active Directory environment. It can also be performed by manually editing the Windows Registry, changing library locations, or with tools such as Tweak UI. Disk quotas can be used to limit the amount of space taken up by users' special folders. The %username% and %userprofile% environment variables can also be used with Folder Redirection. Up to Windows XP, the Application Data, Desktop, My Documents, My Pictures, and Start Menu special folders can be redirected to a file server. Windows XP also implements a Recycle Bin for the My Documents folder. Windows Vista introduces the ability to independently redirect up to 10 user profile sub-folders to a network location. There is also a Management Console snap-in in Windows Vista to allow users to configure Folder Redirection for clients running Windows Vista, Windows XP, and Windows 2000. Each redirected folder in Vista and later also has a Recycle Bin associated with it. Under Windows 7 and later, the following user folders may be redirected: AppData/Roaming, Contacts, Desktop, Downloads, Favorites, Links, Music, Documents, Pictures, Saved Games, Searches, Start Menu, and Videos. The equivalent functionality is achieved in Unix-like systems by using mount or ln and a NFS or CIF.

MORE →
Wikipedia

Timeline of computing 1990–1999

This article presents a detailed timeline of events in the history of computing from 1990 to 1999. For narratives explaining the overall developments, see the history of computing.

MORE →
Wikipedia

Daemon (computing)

In computing, a daemon ( DEE-mən or DAY-mən) is a program that runs as a background process, rather than being under the direct control of an interactive user. Customary convention is to name a daemon process with the letter d as a suffix to indicate that it's a daemon. For example, syslogd is a daemon that implements system logging facility, and sshd is a daemon that serves incoming SSH connections. Even though the concept can apply to many computing systems, the term daemon is used almost exclusively in the context of Unix-based systems. In other contexts, different terms are used for the same concept. Systems often start daemons at boot time that will respond to network requests, hardware activity, or other programs by performing some task. Daemons such as cron may also perform defined tasks at scheduled times.

MORE →
TOPIC OF THE DAY

Greenwood / Black Wall Street

Before the 1921 destruction of Tulsa’s Greenwood District, Black residents had created a remarkable center of business and community life. The district included stores, professional offices, entertainment venues and homes owned by Black citizens. Understanding Greenwood means learning what was built—not only what was burned.

MORE →
TRIVIA QUESTION OF THE DAY

What prosperous Tulsa district became widely known as “Black Wall Street”?

The Greenwood District.