Shell one-liner: Difference between revisions

(→‎sed: add)
imported>Tromp
 
(9 intermediate revisions by 6 users not shown)
Line 125:
{{out}}
<pre>Hello 123</pre>
 
=={{header|Binary Lambda Calculus}}==
Several such one liners are shown on https://www.ioccc.org/2012/tromp/hint.html, such as
<syntaxhighlight lang="bash">echo "*Hello, world" | ./tromp</syntaxhighlight>
<syntaxhighlight lang="bash">echo "00010001100110010100011010000000010110000010010001010111110111101001000110100001110011010000000000101101110011100111111101111000000001111100110111000000101100000110110" | ./tromp -b | head -c 70</syntaxhighlight>
 
=={{header|Bracmat}}==
Line 397 ⟶ 402:
 
<syntaxhighlight lang="unicon">echo "procedure main();write(\"hello world\");end" >hello.icn; unicon hello.icn -x</syntaxhighlight>
 
=={{Header|Insitux}}==
 
When Insitux has been already been installed system-wide (<code>npm i -g insitux</code>).
 
<pre>
$ npx ix -e "(+ 2 2)"
</pre>
 
{{out}}
 
<pre>
4
</pre>
 
=={{header|J}}==
<syntaxhighlight lang="bash">$ jconsole -js "exit echo 'Hello'"
Hello</syntaxhighlight>
</syntaxhighlight>
 
Here, the (empty) result of <code>echo</code> is used as the exit code argument for <code>exit</code>. And, since it's empty, the the default exit code of 0 is what's actually used. The exit command here is used to prevent the default behavior of jconsole (which is to start the J [[wp:Command_shell|command shell]]) and to instead return to the OS command shell.
 
We could have instead used:
 
<syntaxhighlight lang="bash">$ :|jconsole -js "echo 'Hello'"
Hello
</syntaxhighlight>
 
for nearly identical behavior, but this issues J's command prompt before exiting. (But since J's command prompt is three space characters, this would be nearly invisible in many contexts, including here because the mediawiki implementation deletes those trailing spaces when rendering this page into html.)
That said, note that J interpreters can themselves be thought of as [[wp:Command_shell|command shells]].
 
=={{header|Java}}==
Line 450 ⟶ 478:
 
=={{header|Lang}}==
This is an example for the Standard Lang implementation of langLang.
<syntaxhighlight lang="lang">
$ lang -e "fn.println(Hello World)"
</syntaxhighlight>
 
=={{header|langur}}==
=== Linux ===
<syntaxhighlight lang="langur">$ langur -e 'writeln "Are we reaching Fiji?"'
</syntaxhighlight>
 
=== Windows ===
<syntaxhighlight lang="langur">C:\> langur /e 'writeln "Are we reaching Fiji?"'
</syntaxhighlight>
 
{{out}}
<pre>Are we reaching Fiji?</pre>
 
=={{header|Lasso}}==
Line 722 ⟶ 762:
<pre>
Hello World!
</pre>
 
=={{header|RPL}}==
RPL command-line interpreter allows to pass several instructions and values in one line, provided there is no program branch instruction among them. It is nevertheless possible to have a program structure in the line by bracketing it with <code>≪ ≫</code>, which means "this is an unnamed program". Adding the word <code>EVAL</code> at the end will execute the code, otherwise it would stay at level 1 of the stack.
" World" "Hello" SWAP +
 
≪ " World" "Hello" SWAP + ≫ EVAL
This less trivial one-liner example calculates S(5), where S(n) is a Machin-like formula :
≪ 0 0 5 '''FOR''' k 2 k * 1 + → n ≪ -1 k ^ n / 4 5 n ^ / 239 n ^ INV - * + ≫ '''NEXT''' 4 * ≫ EVAL
{{out}}
<pre>
3: "Hello world"
2: "Hello world"
1: 3.14159265262
</pre>
 
Anonymous user