top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

OS: How does the re-direction work internally in unix system ?

+1 vote
275 views

I am looking for internal details of following commands.
$ls * > 1.txt
I know this is very simple command used to re-direct the console output to a file.
But I want to know how does it work internally ? What the system does for this command ?

posted Apr 9, 2016 by Vikram Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

In UNIX, everything is a file. All stdout is by default is the (for example) /dev/tty file which is a device driver hooked up to your console/terminal/window. Output is just sent to that file (device driver) which causes it to be output to whatever you're using for interactive I/O.

All the a command like a.out >xyzzy.txt does is first connect the standard output of the program to that file rather than /dev/tty, hence the output shows up there instead.

answer Apr 16, 2016 by Shivaranjini
Similar Questions
0 votes

It is very basic query but clearing the doubt always make your knowledge stronger.

+2 votes

If I correct , by default main () function has integer return type.
I want to know what happens in the system internally when its return type gets changed from integer to void ?

+4 votes

So many times, we make foreground process to background process in linux system. How does it handle internally ?

...