Copy stdin to stdout: Difference between revisions
Rename Perl 6 -> Raku, alphabetize, minor clean-up
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
|||
Line 2:
Create an executable file that copies stdin to stdout, or else a script that does so through the invocation of an interpreter at the command line.
=={{header|Ada}}==
Line 17 ⟶ 16:
end loop;
end Copy_Stdin_To_Stdout;</lang>
=={{header|Aime}}==
Line 38 ⟶ 36:
END</lang>
=={{
Using the awk interpreter, the following command uses the pattern // (which matches anything) with the default action (which is to print the current line) and so copy lines from stdin to stdut.
<lang AWK>awk "//"</lang>
=={{
<lang C>
#include <stdio.h>
Line 100 ⟶ 98:
}
}</lang>
=={{
<lang Haskell>main = interact id </lang>
Line 131 ⟶ 130:
</pre>
=={{
<lang Julia>while !eof(stdin)
write(stdout, read(stdin, UInt8))
Line 148 ⟶ 147:
<pre>lua -e 'for x in io.lines() do print(x) end'</pre>
=={{
<lang Mercury>
Line 194 ⟶ 193:
</lang>
=={{
<lang nim>stdout.write readAll(stdin)</lang>
=={{
<lang ocaml>try
Line 206 ⟶ 205:
with End_of_file -> ()</lang>
<lang perl>
perl -pe ''
</lang>
▲=={{header|Perl 6}}==
When invoked at a command line: Slightly less magical than Perl / sed. The p flag means automatically print each line of output to STDOUT. The e flag means execute what follows inside quotes. ".lines" reads lines from the assigned pipe (file handle), STDIN by default.▼
<lang perl6>perl6 -pe'.lines'</lang>▼
When invoked from a file: Lines are auto-chomped, so need to re-add newlines (hence .say rather than .print)▼
<lang perl6>.say for lines</lang>▼
=={{header|Phix}}==
Line 230 ⟶ 220:
<lang PicoLisp>(in NIL (echo))</lang>
=={{
<lang Prolog>
%File: stdin_to_stdout.pl
Line 253 ⟶ 243:
<pre>Rscript -e 'cat(readLines(file("stdin")))'</pre>
=={{
<lang racket>#lang racket
Line 262 ⟶ 252:
(loop)]))</lang>
=={{
(formerly Perl 6)
▲When invoked at a command line: Slightly less magical than Perl / sed. The p flag means automatically print each line of output to STDOUT. The e flag means execute what follows inside quotes. ".lines" reads lines from the assigned pipe (file handle), STDIN by default.
▲<lang perl6>perl6 -pe'.lines'</lang>
▲When invoked from a file: Lines are auto-chomped, so need to re-add newlines (hence .say rather than .print)
▲<lang perl6>.say for lines</lang>
In the REXX language, the '''STDIN''' (default input
stream) is normally the console, and
Line 275 ⟶ 274:
end /*while*/ /*stick a fork in it, we're all done. */</lang>
=={{
<lang Rust>use std::io;
Line 282 ⟶ 281:
}</lang>
=={{
<lang scheme>
Line 290 ⟶ 289:
</lang>
=={{
<lang sh>
|