I am a very beginner of unix, and working on putty shell environment.
I know standard input, output, and error are streams and related to file descriptors, but I did not understand clearly what /dev/stdin does.
What is '/dev/stdin/ and how to use?
Is it a special (block or character) file of a device?
$ echo hello | cp /dev/stdin /dev/stdout
and$ cat /dev/stdin >resultfile
to figure out what is the role of /dev/stdin – Godpoong Apr 21 '19 at 02:39file /dev/stdin
. Your path is wrong, the trailing slash is redundant. – Weijun Zhou Apr 21 '19 at 04:30/dev/stdin
to/dev/stdout
, you should usedd if=/dev/stdin of=/dev/stdout
,cp
copies the special file itself, it requires superuser privilege to do thiscp
. After all, it does not make sense to copy the file itself and you should not trysudo cp /dev/stdin /dev/stdout
. Please also checkman dup2
. – Weijun Zhou Apr 21 '19 at 04:39cp /dev/stdin /dev/stdout
works fine. example:echo yup | cp /dev/stdin /dev/stdout
. And this works with both BSD's dup-like/dev/std{in,out}
and with Linux's fake symlinks and quirks. Where did you get that superuser privilege idea from? – Apr 21 '19 at 16:26/dev/
, but now I realize it's wrong. Also I have an aliasedcp
when I did the tests. – Weijun Zhou Apr 21 '19 at 16:37