Shell one-liner: Difference between revisions
Content added Content deleted
m (→[[Shell One Liner#ALGOL 68]]: fix end tag) |
(C) |
||
Line 6: | Line 6: | ||
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}} |
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}} |
||
<lang>$ a68g -e 'print(("Hello",new line))'</lang> |
<lang>$ a68g -e 'print(("Hello",new line))'</lang> |
||
<pre> |
|||
Hello |
|||
</pre> |
|||
=={{header|C}}== |
|||
Not orthodox, but working... (Do not run it into a directory where files with names <tt>T0.c</tt> and <tt>T</tt> exist!) |
|||
<lang> |
|||
$ echo -e "#include<stdio.h>\nint main(){printf(\"Hello\\\n\");return 0;}" >T0.c && |
|||
gcc T0.c -o T && ./T && rm -f T0.c T |
|||
</lang> |
|||
<pre> |
<pre> |
||
Hello |
Hello |
Revision as of 23:30, 8 February 2009
Shell one-liner
You are encouraged to solve this task according to the task description, using any language you may know.
You are encouraged to solve this task according to the task description, using any language you may know.
Execute one line of code from the shell.
ALGOL 68
<lang>$ a68g -e 'print(("Hello",new line))'</lang>
Hello
C
Not orthodox, but working... (Do not run it into a directory where files with names T0.c and T exist!)
<lang> $ echo -e "#include<stdio.h>\nint main(){printf(\"Hello\\\n\");return 0;}" >T0.c &&
gcc T0.c -o T && ./T && rm -f T0.c T
</lang>
Hello
Haskell
<lang> $ ghc -e 'putStrLn "Hello"' Hello </lang>
J
<lang> $ jconsole -js "exit echo 'Hello'" Hello </lang>
OCaml
<lang> $ ocaml <(echo 'print_endline "Hello"') Hello </lang>
Perl
<lang> $ perl -e 'print "Hello\n"' Hello </lang>
PHP
assuming you have the PHP CLI (command-line interface) installed, not just the web server plugin <lang> $ php -r 'echo "Hello\n";' Hello </lang>
Python
<lang> $ python -c 'print "Hello"' Hello </lang>
Ruby
<lang> $ ruby -e 'puts "Hello"' Hello </lang>