Practice
Resources
Contests
Online IDE
New
Free Mock
Events New Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
logo
Events
Attend free live masterclass hosted by top tech professionals
New
Scaler
Explore Offerings by SCALER

Basic Shell Commands

Go to Problems

Piping command in Unix with example

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

for i in {1..30}; do echo $i; done | cut -c 2 | sort | uniq

Output (generated from for i in {1..30}; do echo $i; done ) which will be taken as input by cut :

1
2
3
.
.
.
28
29
30

The output ( generated by cut -c 2 ) which will be taken as input by sort :

(empty)

.
.
.
8
9
0

The output (generated by sort) which will be taken as input by uniq:



.
.
.
9
9
9

Final output (generated by uniq)


0
1
.
.
.
7
8
9

Note: Run commands separately in the terminal for better understanding.

Serious about Learning Scripting ?

Learn this and a lot more with Scaler Academy's industry vetted curriculum.
Shell scripting
Problem Score Companies Time Status
Valid phone number 150
21:58
Lines in a given range 200
28:03
Remove Punctuations 250
12:54
Transform CSV 300
19:13
Excel at your interview with Masterclasses Know More
Certificate included
What will you Learn?
Free Mock Assessment
Fill up the details for personalised experience.
All fields are mandatory
Current Employer *
Enter company name *
Graduation Year *
Select an option *
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
Phone Number *
OTP will be sent to this number for verification
+1 *
+1
Change Number
Phone Number *
OTP will be sent to this number for verification
+1 *
+1
Change Number
Graduation Year *
Graduation Year *
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
*Enter the expected year of graduation if you're student
Current Employer *
Company Name *
Please verify your phone number
Edit
Resend OTP
By clicking on Start Test, I agree to be contacted by Scaler in the future.
Already have an account? Log in
Free Mock Assessment
Instructions from Interviewbit
Start Test