Skip to main content

Posts

Showing posts from December, 2019

Piping - Linux Command

Piping connects STDOUT of one command to STDIN of another STDOUT - Standard Output STDIN - Standard Input Lets take an example : We want to display todays day. Command that we can use: 1. date command to get todays date 2.  cut command. Without using Piping:  To get day, we need to do following steps 1. Save output of date to file 2. Give above file as input to cut command 3. Remove temporary file we created As you see, we got "Sun" as output using cut command. Note:      1. Above cut command -d ' '(delimiter) means cut the input text separated by space and -f (field) means pick 1st field from result      2. < & > are used for redirections. We can avoid creating extra file and instead of 3 commands we can achieve this by using only single command as below. Using Piping:  Yay!!! we got todays day using piping. Redirection of STDOUT breaks pipeline To save snapshot without breaking p...

Sync vs Async vs Parallel with example

Let’s say you have 2 tasks — 1. Boiling the milk 2. Making pizza dough There are various ways to complete both tasks. 1st way — Boil milk first, then make pizza dough. This is called Synchronous i.e. to do next task only after completion of current task. 2nd way — By the time milk boils, we are idle. So meantime make pizza dough. This is called Asynchronous i.e. to do next task in available time while doing current. Now let’s say instead of one dough, we have to make big dough for many pizzas. Now to complete task in less time, we may take help of our friends. We may ask each friend to do one dough. Then merge at the end. This is parallelism i.e. to distribute task among multiple resources in order to complete the task.