Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Pipeline (Unix)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Example === Below is an example of a pipeline that implements a kind of [[spell checker]] for the [[World Wide Web|web]] resource indicated by a [[Uniform Resource Locator|URL]]. An explanation of what it does follows. <syntaxhighlight lang="bash" line=""> curl 'https://en.wikipedia.org/wiki/Pipeline_(Unix)' | sed 's/[^a-zA-Z ]/ /g' | tr 'A-Z ' 'a-z\n' | grep '[a-z]' | sort -u | comm -23 - <(sort /usr/share/dict/words) | less </syntaxhighlight> # '''<code>[[CURL|curl]]</code>''' obtains the [[HTML]] contents of a web page (could use <code>[[wget]]</code> on some systems). # '''<code>[[sed]]</code>''' replaces all characters (from the web page's content) that are not spaces or letters, with spaces. ([[Newline]]s are preserved.) # '''<code>[[tr (program)|tr]]</code>''' changes all of the uppercase letters into lowercase and converts the spaces in the lines of text to newlines (each 'word' is now on a separate line). # '''<code>[[grep]]</code>''' includes only lines that contain at least one lowercase [[alphabetical]] character (removing any blank lines). # '''<code>[[Sort (Unix)|sort]]</code>''' sorts the list of 'words' into alphabetical order, and the <code>-u</code> switch removes duplicates. # '''<code>[[comm (Unix)|comm]]</code>''' finds lines in common between two files, <code>-23</code> suppresses lines unique to the second file, and those that are common to both, leaving only those that are found only in the first file named. The <code>-</code> in place of a filename causes <code>comm</code> to use its standard input (from the pipe line in this case). <code>sort /usr/share/dict/words</code> sorts the contents of the <code>words</code> file alphabetically, as <code>comm</code> expects, and <code><( ... )</code> outputs the results to a temporary file (via [[process substitution]]), which <code>comm</code> reads. The result is a list of words (lines) that are not found in /usr/share/dict/words. # '''<code>[[less (Unix)|less]]</code>''' allows the user to page through the results.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)