Copy stdin to stdout: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(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>
 
=={{Headerheader|AWK}}==
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>
 
=={{Headerheader|C}}==
<lang C>
#include <stdio.h>
Line 100 ⟶ 98:
}
}</lang>
 
=={{Headerheader|Haskell}}==
<lang Haskell>main = interact id </lang>
 
Line 131 ⟶ 130:
</pre>
 
=={{Headerheader|Julia}}==
<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>
 
=={{Headerheader|Mercury}}==
<lang Mercury>
 
Line 194 ⟶ 193:
</lang>
 
=={{Headerheader|Nim}}==
 
<lang nim>stdout.write readAll(stdin)</lang>
 
=={{Headerheader|OCaml}}==
 
<lang ocaml>try
Line 206 ⟶ 205:
with End_of_file -> ()</lang>
 
=={{header|Perl 6}}==
 
=={{Header|Perl}}==
<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>
 
=={{Headerheader|Prolog}}==
<lang Prolog>
%File: stdin_to_stdout.pl
Line 253 ⟶ 243:
<pre>Rscript -e 'cat(readLines(file("stdin")))'</pre>
 
=={{Headerheader|Racket}}==
<lang racket>#lang racket
 
Line 262 ⟶ 252:
(loop)]))</lang>
 
=={{Headerheader|REXXRaku}}==
(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>
 
=={{Headerheader|PerlREXX}}==
In the REXX language, &nbsp; the &nbsp; '''STDIN''' &nbsp; (default input
stream) &nbsp; is normally the console, &nbsp; and
Line 275 ⟶ 274:
end /*while*/ /*stick a fork in it, we're all done. */</lang>
 
=={{Headerheader|Rust}}==
<lang Rust>use std::io;
 
Line 282 ⟶ 281:
}</lang>
 
=={{Headerheader|Scheme}}==
 
<lang scheme>
Line 290 ⟶ 289:
</lang>
 
=={{Headerheader|sed}}==
 
<lang sh>
10,333

edits