• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Examples of Pipe or Pipelines Command

By Abhishek Ghosh August 25, 2014 9:41 pm Updated on August 25, 2014

Examples of Pipe or Pipelines Command

Advertisement

In UNIX, Unix like operating systems including Linux, the shell of the OS have a mechanism called pipe or pipeline which looks like this |. In fact this ASCII vertical bar character “|” is named as pipe character. Unless you are from old schooling, each and every linked article are important; most IT related professional bachelors degree programs exclude the parts which are quite important in real life. Also, you should know what is Terminal, historically we are using UNIX more effectively now than we used to do 40 years back – from Android, iOS to major servers – all runs some version of UNIX or Unix like OS.  In this article we will not only discuss about the Examples of Pipe or Pipelines Command, but also go to a bit history. Specifically if you are a software engineer but it was not your major, these are very important and often neglected area. Just like, typing without looking at the keyboard without doing typographical errors need a huge time to master, application of piping needs long term usage.

 

History of Pipe or Pipelines Command

 

A pipeline consists of a chain of processing elements arranged to give the output of each element as in sequence; the name is by analogy to a physical pipeline. Usually there is some buffering the consecutive elements. The shell of the operating systems have a mechanism called pipe. This mechanism allows to chain the process so that the output of one process feeds directly. Each connection is implemented by an anonymous pipe. Programs filters are often used in this configuration. It is Douglas McIlroy who invented this concept for Unix shells. A very basic example of piping is :

Vim
1
programme1 | programme2

The program programme1 is executed by the system that sends the results to programme2 which in turn returns the results to the standard output of the system. Working example :

Advertisement

---

Vim
1
cut -d "" -f1 <access.log | sort | uniq -c | sort-rn | less

This display the client IP addresses that accessed most frequently visited to a web server running Apache. Standard error (stderr) is an output stream typically used by programs to output error messages or diagnostics. Pipeline escapes this stderr. If you run man stderr on OS X 10.9.x, you will get BSD Kernel Interfaces Manual.

We usually use simple pipelines where the shell connects a series of sub-processes via pipes and executes external commands within each sub-process. But it is possible for the shell to perform processing directly, this is called Pipemill :

Vim
1
2
command | while read var1 var2 ...; do
   done

this is a subshell – var1, var2 etc. will not be available after the while loop terminates.

Examples of Pipe or Pipelines Command

 

Examples of Pipe or Pipelines Command

 

Our Tar Extract Progress Bar tutorial uses extreme level of piping. Run this on OS X :

Vim
1
ls -al | more

UNIX and BSD has UNIX Wheel Group. It gave me output :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
âžœ  ~  ls -al | more
total 1077960
drwxr-xr-x+ 160 abhishekghosh  staff       5440 Aug 26 02:35 .
drwxr-xr-x    5 root           admin        170 Jul  5 13:24 ..
-rw-r--r--@   1 abhishekghosh  staff         16 Dec 13  2013 .CF89AA64
-rw-------    1 abhishekghosh  staff          3 Jan 17  2014 .CFUserTextEncoding
-rw-r--r--@   1 abhishekghosh  staff      39940 Aug 24 16:29 .DS_Store
drwx------    9 abhishekghosh  staff        306 Aug 23 14:01 .Trash
-rw-------    1 abhishekghosh  staff         49 Mar 16 01:04 .Xauthority
drwxr-xr-x    4 abhishekghosh  staff        136 Dec 30  2012 .adobe
-rw-------    1 abhishekghosh  staff        170 Mar 13  2013 .af_token
-rw-------    1 abhishekghosh  staff      12288 Jul 27  2013 .app.js.swp
-rw-------    1 abhishekghosh  staff       2075 Jul 20 00:24 .bash_history
-rw-r--r--    1 abhishekghosh  staff        101 Jul 11 13:44 .bash_profile
drwxr-xr-x    3 abhishekghosh  staff        102 Feb 28 19:19 .bundler
drwx------    4 abhishekghosh  staff        136 Aug  8  2013 .cache
drwxr-xr-x    3 abhishekghosh  staff        102 Feb 21  2014 .cocoapods
drwx------    6 abhishekghosh  staff        204 Jan 18  2014 .config
drwx------    3 abhishekghosh  staff        102 Jan  3  2013 .cups
drwx------    3 abhishekghosh  staff        102 Feb 22  2013 .dbus-keyrings
drwx------    4 abhishekghosh  staff        136 Feb 26  2013 .emacs.d
-rw-------    1 abhishekghosh  staff      12288 Aug 31  2013 .example.html.swp
drwx------    4 abhishekghosh  staff        136 Dec 20  2012 .fbcmd
drwx------   11 abhishekghosh  staff        374 Aug 14 13:34 .filezilla
drwxr-xr-x    3 abhishekghosh  staff        102 Nov 25  2012 .fontconfig

I am not root. In the same way, to list of all sub-directories in the current directory, we can use :

Vim
1
ls -al | grep '^d'

I used d to grab drwx! Here is a combination of pipeline, redirection (>) and usage of && :

Vim
1
ls | head -3 | tail -1 > myoutput.txt && nano myoutput.txt

If I stopped before the && my output.txt, I had to work more, it would waste time; it would demand to type cat myoutput.txt – Piping is for not saving time, it is for logically making the things working. Run man pipe on OS X, you will get pipe (8) – Postfix delivery to external command manual. tee kind of sanitizes the raw usage of redirection :

Vim
1
ps -ax | tee allprocess.txt | more

You can run diff to compare over ssh :

Vim
1
ssh user@remote-host "cat path/file.name" | diff path/file.name -

Practically you need to understand which thing can be connected with which to get a practical result. Unless you have sufficient knowledge on UNIX commands, pipe will remain far from being useful. These are safer examples, do not run others’ pipe without knowing what are the individual commands can do.

Tagged With c99madshell Drwxr Off server ip drwxr-xr

This Article Has Been Shared 846 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Examples of Pipe or Pipelines Command

  • How pirated Windows 7 logo has spread all over the Internet

    Author writes on how the pirated Windows 7 logos has spread all over the Internet and even suppressed the original official Microsoft logo.

  • Tethering : What is Tethering of Mobile Devices

    Tethering refers to the connection of a smartphone with a PC or PDA for sharing internet connection via GSM or UMTS. The phone is taking the role of modem here.

  • Digital Watermarking : How it Works

    Digital Watermarking is defined as non detectable marking on images, videos, 3D data, audio or text. They can be read by computer assisted methods.

  • Battery : The Everyday Used Powerhouse

    Battery interconnection of several similar is galvanic cells or elements. Since 1850 Batteries are powering simple bulb to complex electronic component of 2012.

  • Socket in Computer Network

    Socket is a software module that allows a computer program with a computer network to exchange data and connect with other computers.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Four Foolproof Tips To Never Run Out Of Blog Ideas For Your Website March 28, 2023
  • The Interactive Entertainment Serving as a Tech Proving Ground March 28, 2023
  • Is it Good to Run Apache Web server and MySQL Database on Separate Cloud Servers? March 27, 2023
  • Advantages of Cloud Server Over Dedicated Server for Hosting WordPress March 26, 2023
  • Get Audiophile-Grade Music on Your Smartphone March 25, 2023

About This Article

Cite this article as: Abhishek Ghosh, "Examples of Pipe or Pipelines Command," in The Customize Windows, August 25, 2014, March 29, 2023, https://thecustomizewindows.com/2014/08/examples-of-pipe-or-pipelines-command/.

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT