welcome to the video tutorial on Linux
pipes GRE P and sort command if you are
new to Linux you might wonder what role
do pipes play and running the operating
system while they are not the real pipes
that you have in mind the symbol pipe
denotes a pipe and Linux if you want to
use two or more commands at the same
time and run them consecutively you can
use pipes pipes enable UNIX or Linux
users to create powerful commands which
can perform complex tasks in a jiffy let
us understand this with an example when
you use the cat command to view a file
like the file fruits here which has a
lot of pages the prompt quickly jumps to
the last page of the file and you do not
see the content in the middle to avoid
this you can pipe the output of the cat
command to less which will show you only
once call lengths of content at a time
this way you can scroll the file content
using the arrow keys and once you reach
the end of the file has cue to exit
instead of less you can also use the PG
and more commands and you can view the
file in digestible bits and scroll down
by simply hitting the Enter key once you
reach the end of the file you can again
hit the enter key and you would see the
command prompt this was about reading
the file so what if you have to search a
file for text or a piece of information
for this we need to use the GRE key
command using this command you can scan
a document and reverse you can also
customize the search results the way you
want the syntax for this command is GRE
P space the search strength let us see
it in action these are the contents of
the file fruits now we will use the GRE
P command to look for avocado the syntax
for this would be cat space the file
name space the pipe then the GRE P
command followed by the string that we
want to search which would be avocado in
this case hitting Enter would search the
file fruits for the string avocado
let's also use the same command to
search for melon this is how the command
search for the desired strength in a
file you can use the following options
with the GI EP command so if you want to
display the lines that do not match the
searched strength you can use the option
- V with the GI EP command let us try
some of them on terminal here we will
try the option I with the GR EP command
the I option filters the string which is
a from all the lines in the fire this is
why we would get this result the sort
command comes in handy when you are
trying to list the contents of a file
alphabetically the syntax for this
command is sort space filename let us
say we want to sort the content of the
same file fruits alphabetically right
now we see that the name of fruits are
all jumbled up using the sort command we
will easily be able to do it in a jiffy
you can use the following extensions for
the sort command and get different
results so if you want to reverse the
sorting of the contents of a file you
can use the option hyphen R let us try
it and see how it works out
using reverse sorting we have changed
the alphabetical order of the contents
of the fruit file it is now understand
what our filters filter is the output
from the first command which becomes the
input for the second one
when you pipe to commands the filtered
output of the first command is given to
the next one let us understand this with
the help of an example we will again use
the same file for this example now we
want to highlight only the lines that do
not contain the character a in lowercase
you will do it this way
this is how we can filter the output of
the first command and use it as the
input for the second one now what if we
want this result in the reverse order we
will need to run this command or the
same
here the cat command will display the
contents of the file fruit the result
would be outputted to the GRE P command
which will not search for strengths
which contain the character a the output
of this command would be then worked on
by the sort command to display the
result in the reverse order this is how
we can use filters and summarize what we
have learned today
pipes help combine two or more commands
a filter in a pipe is an output of one
command which serves as the input to the
next the GRE P command can be used to
find strengths and values in a text
document sort command sorts out the
content of a file alphabetically
less PG and more commands are used for
dividing a long file into readable bits
thank you for watching I will see you in
the next tutorial