Unix/Linux Tutorials | Input,Output and Error 'Redirection' In Simple Way | by DURGA Sir

preview_player
Показать описание
Input,Output and Error "Redirection" In Simple Way
=========================================
Input and output of commands:
-------------------------------------------------
Diagram

Commands can take input, perform certain operation and produces the corresponding output. While executing command if anything goes wrong then we will get error message.

Command can take input either from standard input or from command line arguments.
Command will produce results to either standard output or standard error.

Standard Input, Standard Ouput and Standard Error are data streams and can flow from one place to another place. Hence redirection and piping concepts are applicable for these.

Command Line arguments are static and these are not streams. Hence redirection and piping concepts are not applicable to command line arguments.

These data streams are associated with some numbers.
Standard Input associated with 0.
Standard Output associated with 1.
Standard Error associated with 2.

Bydefault standard input connected to keyboard, Standard output and Standard Error are connected to Terminal. But based on our requirement we can redirect these streams.

Standard Input from the keyboard and output to Standard output device:
----------------------------------------------------------------------
For the cat command, if we are not providing any arguments, then the input will be taken from standard input device (keyboard) and display the output to the standard output device.

This data is from keyboard
This data is from keyboard
This is my second line
This is my second line
ctrl+d

Input from command line arguments and error messages to the standard error device( terminal):
-----------------------------------------------------------------------------------

We are providing filename as command line argument to the rm command.
If the specified file not available then we will get error and that error message will be printed to the Standard Error device (Terminal).

Note:
Some commands can accept only standard input and some commands can accept only command line arguments and some commands can accept both.

1. rm command can accept only command line arguments.
rm file1 file2
2. echo command can accept only command line arguments.
echo "durgasoft"
3. cat command can accept both command line arguments and standard input

Redirection:
===========
As Standard Input, Standard Ouput and Standard Error are data streams and we can redirect these streams.
Рекомендации по теме
Комментарии
Автор

What an explanation sir 🤗👍We are blessed to listen your classes

lokesht
Автор

Hatts off all durgasoft people's....u all are amazing...thnx for this...

rajdulari_tadwal
Автор

Best ever teacher I have ever experience in all my Life.

usmanjawaid
Автор

Nujamga meru devudu sir.
Maa trainer 1 hour cheppadu. Kani em Arkham kaledu. Mee explanation keka sir

Santosh_bungatavula
Автор

Well explained sir..thanks a lot.
My confusion is cleared now.🤝👌

malli_malta
Автор

Listening Your lecures on Java 7 and practicing i passed the whole OCJP 7 exams.

usmanjawaid
Автор

thank you sir! you are truly a students' teacher.

madrasapattinam