• 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
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

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • Changing Data With cURL for OpenStack Swift (HP Cloud CDN)

    Changing Data With cURL For Object is Quite Easy in OpenStack Swift. Here Are Examples With HP Cloud CDN To Make it Clear. Official Examples Are Bad.

  • WordPress & PHP : Different AdSense Units on Mobile Devices

    Here is How To Serve Different AdSense Units on Mobile Devices on WordPress With PHP. WordPress Has Function Which Can Be Used In Free Way.

  • Command Prompt Commands : Alphabetical list of all commands in Windows 7

    Command Prompt Commands in Windows 7 provides the user access to 180+ command line commands. Here is a list of 200 Command Prompt Commands in Windows 7.

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

  • PowerAmp Settings for Higher Sound QualityOctober 4, 2023
  • Affordable Earphone/IEM for Audiophiles: HiFiMan RE-400 WaterlineOctober 2, 2023
  • What is Hardware Security Module (HSM)September 30, 2023
  • Transducer Technologies of HeadphonesSeptember 28, 2023
  • What is Analog-to-Digital Converter (ADC)September 27, 2023
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