bala@hp:~$ echo "Hello World" > stdout
bala@hp:~$ cat stdout
Hello World
bala@hp:~$ echo "Hello World" > /dev/stdout
Hello World
Kindly clarify what is the difference between stdout
and /dev/stdout
Note :
bala@hp:~$ file stdout
stdout: ASCII text
bala@hp:~$ file /dev/stdout
/dev/stdout: symbolic link to `/proc/self/fd/1'
Kindly help to know the difference .
In your case
stdout
is a normal file, created in the same directory where you're running the command.So, when you're redirecting the output of
echo
tostdout
, it is written to the file. You need to docat
(as example, here you did) in order to see the content on screen here./dev/stdout
is a device file, which is a link to/proc/self/fd/1
, which means it is referring to the file descriptor 1 held by the current process.So, when you're redirecting the output of
echo
to/dev/stdout
, it is sent to the standard output (the screen) directly.