Shell one-liner: Difference between revisions

Content added Content deleted
m (syntax highlighting fixup automation)
Line 25: Line 25:


=={{header|ACL2}}==
=={{header|ACL2}}==
<lang bash>$ acl2 <<< '(cw "Hello.")'</lang>
<syntaxhighlight lang="bash">$ acl2 <<< '(cw "Hello.")'</syntaxhighlight>


=={{header|Ada}}==
=={{header|Ada}}==
Line 31: Line 31:
'''under a unixoid shell''' (bash, sh, ...)
'''under a unixoid shell''' (bash, sh, ...)


<lang bash>echo 'with Ada.text_IO; use Ada.text_IO; procedure X is begin Put("Hello!"); end X;' > x.adb; gnatmake x; ./x; rm x.adb x.ali x.o x</lang>
<syntaxhighlight lang="bash">echo 'with Ada.text_IO; use Ada.text_IO; procedure X is begin Put("Hello!"); end X;' > x.adb; gnatmake x; ./x; rm x.adb x.ali x.o x</syntaxhighlight>


Note that this mercilessly overwrites and later deletes any files x.adb, x.ali, x,o and x in the current directory.
Note that this mercilessly overwrites and later deletes any files x.adb, x.ali, x,o and x in the current directory.


=={{header|Aikido}}==
=={{header|Aikido}}==
<lang aikido>echo 'println ("Hello")' | aikido</lang>
<syntaxhighlight lang="aikido">echo 'println ("Hello")' | aikido</syntaxhighlight>


=={{header|Aime}}==
=={{header|Aime}}==
<lang sh>$ src/aime -c 'o_text("Hello, World!\n");'</lang>
<syntaxhighlight lang="sh">$ src/aime -c 'o_text("Hello, World!\n");'</syntaxhighlight>


=={{header|ALGOL 68}}==
=={{header|ALGOL 68}}==
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386 - Interpret straight off}}
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386 - Interpret straight off}}
<lang bash>$ a68g -e 'print(("Hello",new line))'</lang>
<syntaxhighlight lang="bash">$ a68g -e 'print(("Hello",new line))'</syntaxhighlight>
Output:
Output:
<pre>Hello</pre>
<pre>Hello</pre>
{{works with|ELLA ALGOL 68|Any - tested with release 1.8.8d.fc9.i386 - translate to [[C]] and then compile and run}}
{{works with|ELLA ALGOL 68|Any - tested with release 1.8.8d.fc9.i386 - translate to [[C]] and then compile and run}}
For an [[ELLA ALGOL 68]] one-liner, merge these lines of shell code:
For an [[ELLA ALGOL 68]] one-liner, merge these lines of shell code:
<lang bash>code='print(("Hello", new line))'
<syntaxhighlight lang="bash">code='print(("Hello", new line))'
a=/tmp/algol$$ s=/usr/share/algol68toc;
a=/tmp/algol$$ s=/usr/share/algol68toc;
echo -e "PROGRAM algol$$ CONTEXT VOID\nUSE standard\nBEGIN\n$code\nEND\nFINISH\n" > $a.a68 &&
echo -e "PROGRAM algol$$ CONTEXT VOID\nUSE standard\nBEGIN\n$code\nEND\nFINISH\n" > $a.a68 &&
a68toc -lib $s -dir $s -uname TMP -tmp $a.a68 && rm $a.a68 &&
a68toc -lib $s -dir $s -uname TMP -tmp $a.a68 && rm $a.a68 &&
gcc $s/Afirst.o $a.c -l{a68s,a68,m,c} -o $a && rm $a.c &&
gcc $s/Afirst.o $a.c -l{a68s,a68,m,c} -o $a && rm $a.c &&
$a; rm $a</lang>
$a; rm $a</syntaxhighlight>
Output:
Output:
<pre>Hello</pre>
<pre>Hello</pre>


=={{header|AppleScript}}==
=={{header|AppleScript}}==
<lang AppleScript>osascript -e 'say "Hello, World!"'</lang>
<syntaxhighlight lang="applescript">osascript -e 'say "Hello, World!"'</syntaxhighlight>


=={{header|Arturo}}==
=={{header|Arturo}}==
Line 64: Line 64:
You may run any arbitrary code string directly using the <code>-e</code> (or <code>--evaluate</code>) flag:
You may run any arbitrary code string directly using the <code>-e</code> (or <code>--evaluate</code>) flag:


<lang bash>$ arturo -e:"print {Hello World!}"</lang>
<syntaxhighlight lang="bash">$ arturo -e:"print {Hello World!}"</syntaxhighlight>


{{out}}
{{out}}
Line 72: Line 72:
=={{header|AWK}}==
=={{header|AWK}}==
Maybe the most common way one can use awk is from the command line for one-liners, feeding the interpreter with an input.
Maybe the most common way one can use awk is from the command line for one-liners, feeding the interpreter with an input.
<lang bash>$ awk 'BEGIN { print "Hello"; }'</lang>
<syntaxhighlight lang="bash">$ awk 'BEGIN { print "Hello"; }'</syntaxhighlight>


A more "complex" and "real" example:
A more "complex" and "real" example:
<lang bash>$ awk '/IN/ { print $2, $4; }' <input.txt</lang>
<syntaxhighlight lang="bash">$ awk '/IN/ { print $2, $4; }' <input.txt</syntaxhighlight>


''Select'' field 2 and 4 of lines matching the regular expression <tt>/IN/</tt> (i.e. where IN appears)
''Select'' field 2 and 4 of lines matching the regular expression <tt>/IN/</tt> (i.e. where IN appears)
Line 81: Line 81:
=={{header|BASIC}}==
=={{header|BASIC}}==
The name of the BASIC executable will vary (common ones are ''basic'', ''bas'', and ''bwbasic''), but in general, a short program can be piped to the interpreter like any other language:
The name of the BASIC executable will vary (common ones are ''basic'', ''bas'', and ''bwbasic''), but in general, a short program can be piped to the interpreter like any other language:
<lang bash>echo 'print "foo"'|basic</lang>
<syntaxhighlight lang="bash">echo 'print "foo"'|basic</syntaxhighlight>


Note that under Windows (and presumably DOS) the two apostrophes (a.k.a. single quotes) should be omitted, since Windows doesn't remove them from the piped text (and the apostrophe is the comment character in many modern BASICs):
Note that under Windows (and presumably DOS) the two apostrophes (a.k.a. single quotes) should be omitted, since Windows doesn't remove them from the piped text (and the apostrophe is the comment character in many modern BASICs):
<lang dos>echo print "foo"|basic</lang>
<syntaxhighlight lang="dos">echo print "foo"|basic</syntaxhighlight>


Also, some popular interpreters (including [http://www.moria.de/~michael/bas/ Michael Haardt's '''bas'''] and [[Chipmunk Basic]]) will include an extra prompt before exiting unless you include <code>exit</code> or <code>system</code> (depending on the specific interpreter's syntax). This sample output shows both with and without <code>system</code> in bas:
Also, some popular interpreters (including [http://www.moria.de/~michael/bas/ Michael Haardt's '''bas'''] and [[Chipmunk Basic]]) will include an extra prompt before exiting unless you include <code>exit</code> or <code>system</code> (depending on the specific interpreter's syntax). This sample output shows both with and without <code>system</code> in bas:
Line 104: Line 104:
On the ZX Spectrum, the ROM basic allows direct commands to be entered from the system prompt:
On the ZX Spectrum, the ROM basic allows direct commands to be entered from the system prompt:


<lang zxbasic>PRINT "Hello World!"</lang>
<syntaxhighlight lang="zxbasic">PRINT "Hello World!"</syntaxhighlight>


==={{header|BaCon}}===
==={{header|BaCon}}===
Line 111: Line 111:
then compile a.bac using bacon then run ./a
then compile a.bac using bacon then run ./a


<lang bash>
<syntaxhighlight lang="bash">
echo "PRINT \"Hello World\" " > a.bac && bacon a && ./a
echo "PRINT \"Hello World\" " > a.bac && bacon a && ./a
</lang>
</syntaxhighlight>


Converting 'a.bac'... done, 2 lines were processed in 0.003 seconds.
Converting 'a.bac'... done, 2 lines were processed in 0.003 seconds.
Line 122: Line 122:


=={{header|Bc}}==
=={{header|Bc}}==
<lang bash>$ echo 'print "Hello "; var=99; ++var + 20 + 3' | bc</lang>
<syntaxhighlight lang="bash">$ echo 'print "Hello "; var=99; ++var + 20 + 3' | bc</syntaxhighlight>
{{out}}
{{out}}
<pre>Hello 123</pre>
<pre>Hello 123</pre>
Line 130: Line 130:


DOS:
DOS:
<lang bracmat>bracmat "put$tay$(e^x,x,20)&"</lang>
<syntaxhighlight lang="bracmat">bracmat "put$tay$(e^x,x,20)&"</syntaxhighlight>
Linux:
Linux:
<lang bracmat>bracmat 'put$tay$(e^x,x,10)&'</lang>
<syntaxhighlight lang="bracmat">bracmat 'put$tay$(e^x,x,10)&'</syntaxhighlight>
Output:
Output:
<pre> 1
<pre> 1
Line 158: Line 158:
=={{header|Burlesque}}==
=={{header|Burlesque}}==


<lang>
<syntaxhighlight lang="text">
Burlesque.exe --no-stdin "5 5 .+"
Burlesque.exe --no-stdin "5 5 .+"
</syntaxhighlight>
</lang>


Using the official interpreter.
Using the official interpreter.
Line 169: Line 169:
delete it to avoid to call another shell/system dependent command/program). The
delete it to avoid to call another shell/system dependent command/program). The
''current directory'' is not specified by <tt>./</tt> in every system...
''current directory'' is not specified by <tt>./</tt> in every system...
<lang bash>$ echo 'main() {printf("Hello\n");}' | gcc -w -x c -; ./a.out</lang>
<syntaxhighlight lang="bash">$ echo 'main() {printf("Hello\n");}' | gcc -w -x c -; ./a.out</syntaxhighlight>


=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==
Line 175: Line 175:


Requires PowerShell 2:
Requires PowerShell 2:
<lang powershell>> Add-Type -TypeDefinition "public class HelloWorld { public static void SayHi() { System.Console.WriteLine(""Hi!""); } }"
<syntaxhighlight lang="powershell">> Add-Type -TypeDefinition "public class HelloWorld { public static void SayHi() { System.Console.WriteLine(""Hi!""); } }"
> [HelloWorld]::SayHi()
> [HelloWorld]::SayHi()
Hi!</lang>
Hi!</syntaxhighlight>


=={{header|Clojure}}==
=={{header|Clojure}}==
Line 184: Line 184:
clj-env-dir comes with clojure-contrib.
clj-env-dir comes with clojure-contrib.


<lang bash>$ clj-env-dir -e "(defn add2 [x] (inc (inc x))) (add2 40)"
<syntaxhighlight lang="bash">$ clj-env-dir -e "(defn add2 [x] (inc (inc x))) (add2 40)"
#'user/add2
#'user/add2
42</lang>
42</syntaxhighlight>


=={{header|CMake}}==
=={{header|CMake}}==
This only works with [[Unix]] systems that have the device node <code>/dev/stdin</code>.
This only works with [[Unix]] systems that have the device node <code>/dev/stdin</code>.


<lang bash>echo 'message(STATUS "Goodbye, World!")' | cmake -P /dev/stdin</lang>
<syntaxhighlight lang="bash">echo 'message(STATUS "Goodbye, World!")' | cmake -P /dev/stdin</syntaxhighlight>


=={{header|COBOL}}==
=={{header|COBOL}}==
Works with GnuCOBOL 2.0 or later
Works with GnuCOBOL 2.0 or later


<lang bash>echo 'display "hello".' | cobc -xFj -frelax -</lang>
<syntaxhighlight lang="bash">echo 'display "hello".' | cobc -xFj -frelax -</syntaxhighlight>


Longer, but avoids two relaxed syntax warnings:
Longer, but avoids two relaxed syntax warnings:
<lang bash>echo 'id division. program-id. hello. procedure division. display "hello".' | cobc -xFj -</lang>
<syntaxhighlight lang="bash">echo 'id division. program-id. hello. procedure division. display "hello".' | cobc -xFj -</syntaxhighlight>


=={{header|Common Lisp}}==
=={{header|Common Lisp}}==
Line 205: Line 205:


{{works with|SBCL}}
{{works with|SBCL}}
<lang bash>sbcl --noinform --eval '(progn (princ "Hello") (terpri) (quit))'</lang>
<syntaxhighlight lang="bash">sbcl --noinform --eval '(progn (princ "Hello") (terpri) (quit))'</syntaxhighlight>
{{works with|CLISP}}
{{works with|CLISP}}
<lang bash>clisp.exe -q -x "(progn (format t \"Hello from CLISP\") (quit))"</lang>
<syntaxhighlight lang="bash">clisp.exe -q -x "(progn (format t \"Hello from CLISP\") (quit))"</syntaxhighlight>


=={{header|D}}==
=={{header|D}}==
{{works with|D|2}}
{{works with|D|2}}
requires [https://github.com/D-Programming-Language/tools/blob/master/rdmd.d rdmd]
requires [https://github.com/D-Programming-Language/tools/blob/master/rdmd.d rdmd]
<lang d>rdmd --eval="writeln(q{Hello World!})"</lang>
<syntaxhighlight lang="d">rdmd --eval="writeln(q{Hello World!})"</syntaxhighlight>
<pre>Hello World!</pre>
<pre>Hello World!</pre>


=={{header|Dc}}==
=={{header|Dc}}==
<lang bash>dc -e '22 7/p'</lang>
<syntaxhighlight lang="bash">dc -e '22 7/p'</syntaxhighlight>
=={{header|Delphi}}==
=={{header|Delphi}}==
Run in cmd.exe.
Run in cmd.exe.
<lang Batch>echo program Prog;begin writeln('Hi');end. >> "./a.dpt" & dcc32 -Q -CC -W- "./a.dpt" & a.exe</lang>
<syntaxhighlight lang="batch">echo program Prog;begin writeln('Hi');end. >> "./a.dpt" & dcc32 -Q -CC -W- "./a.dpt" & a.exe</syntaxhighlight>
The output has the default Delphi header, before the output of executable ("Hi").
The output has the default Delphi header, before the output of executable ("Hi").


=={{header|E}}==
=={{header|E}}==
<lang bash>rune --src.e 'println("Hello")'</lang>
<syntaxhighlight lang="bash">rune --src.e 'println("Hello")'</syntaxhighlight>


The <code>--src</code> option ends with the the filename extension the provided type of program would have:
The <code>--src</code> option ends with the the filename extension the provided type of program would have:


<lang>rune --src.e-awt 'def f := &lt;swing:makeJFrame>("Hello"); f.show(); f.addWindowListener(def _{to windowClosing(_) {interp.continueAtTop()} match _{}}); interp.blockAtTop()'</lang>
<syntaxhighlight lang="text">rune --src.e-awt 'def f := &lt;swing:makeJFrame>("Hello"); f.show(); f.addWindowListener(def _{to windowClosing(_) {interp.continueAtTop()} match _{}}); interp.blockAtTop()'</syntaxhighlight>


=={{header|Elixir}}==
=={{header|Elixir}}==
<lang Elixir>$ elixir -e "IO.puts 'Hello, World!'"
<syntaxhighlight lang="elixir">$ elixir -e "IO.puts 'Hello, World!'"
Hello, World!</lang>
Hello, World!</syntaxhighlight>


=={{header|Emacs Lisp}}==
=={{header|Emacs Lisp}}==
<lang bash>emacs -batch -eval '(princ "Hello World!\n")' </lang>
<syntaxhighlight lang="bash">emacs -batch -eval '(princ "Hello World!\n")' </syntaxhighlight>
Or another example that does something useful: indent a [[C]] source file:
Or another example that does something useful: indent a [[C]] source file:
<lang bash>emacs -batch sample.c --eval '(indent-region (point-min) (point-max) nil)' -f save-buffer</lang>
<syntaxhighlight lang="bash">emacs -batch sample.c --eval '(indent-region (point-min) (point-max) nil)' -f save-buffer</syntaxhighlight>


=={{header|Erlang}}==
=={{header|Erlang}}==
Erlang always starts other applications that can run in parallel in the background, and as such will not die by itself. To kill erl, we sequentially run the 'halt' function from the 'erlang' module (the -S is there to guarantee 'halt' will be evaluated after the io function).
Erlang always starts other applications that can run in parallel in the background, and as such will not die by itself. To kill erl, we sequentially run the 'halt' function from the 'erlang' module (the -S is there to guarantee 'halt' will be evaluated after the io function).
<lang bash>$ erl -noshell -eval 'io:format("hello~n").' -s erlang halt
<syntaxhighlight lang="bash">$ erl -noshell -eval 'io:format("hello~n").' -s erlang halt
hello</lang>
hello</syntaxhighlight>


=={{header|F_Sharp|F#}}==
=={{header|F_Sharp|F#}}==
<lang cmd>> echo printfn "Hello from F#" | fsi --quiet
<syntaxhighlight lang="cmd">> echo printfn "Hello from F#" | fsi --quiet
Hello from F#</lang>
Hello from F#</syntaxhighlight>


=={{header|Factor}}==
=={{header|Factor}}==
<lang bash>$ factor -run=none -e="USE: io \"hi\" print"</lang>
<syntaxhighlight lang="bash">$ factor -run=none -e="USE: io \"hi\" print"</syntaxhighlight>


=={{header|Forth}}==
=={{header|Forth}}==
{{works with|GNU Forth}}
{{works with|GNU Forth}}
<lang bash>$ gforth -e ".( Hello) cr bye"
<syntaxhighlight lang="bash">$ gforth -e ".( Hello) cr bye"
Hello</lang>
Hello</syntaxhighlight>


=={{header|Fortran}}==
=={{header|Fortran}}==
This example, stolen from the [[Shell_one-liner#c|c]] example is subject to the same caveats. While contrived, FORTRAN as a one liner can easily handle some unique tasks. Let's plot a Bessel function:
This example, stolen from the [[Shell_one-liner#c|c]] example is subject to the same caveats. While contrived, FORTRAN as a one liner can easily handle some unique tasks. Let's plot a Bessel function:
<lang bash>
<syntaxhighlight lang="bash">
$ gawk 'BEGIN{print"write(6,\"(2(g12.3,x))\")(i/10.0,besj1(i/10.0), i=0,1000)\nend";exit(0)}'|gfortran -ffree-form -x f95 - | gnuplot -p -e 'plot "<./a.out" t "Bessel function of 1st kind" w l'
$ gawk 'BEGIN{print"write(6,\"(2(g12.3,x))\")(i/10.0,besj1(i/10.0), i=0,1000)\nend";exit(0)}'|gfortran -ffree-form -x f95 - | gnuplot -p -e 'plot "<./a.out" t "Bessel function of 1st kind" w l'
</syntaxhighlight>
</lang>
Sorry, I don't know how to upload my jpeg file for the Image tag. Let's use the dumb display instead.
Sorry, I don't know how to upload my jpeg file for the Image tag. Let's use the dumb display instead.
<pre>
<pre>
Line 288: Line 288:
=={{header|Free Pascal}}==
=={{header|Free Pascal}}==
The FPC (Free Pascal compiler) comes with the utility <tt>instantfpc(1)</tt> or <tt>ifpc(1)</tt> for short (Debian or FreeBSD package <tt>fpc-utils</tt>):
The FPC (Free Pascal compiler) comes with the utility <tt>instantfpc(1)</tt> or <tt>ifpc(1)</tt> for short (Debian or FreeBSD package <tt>fpc-utils</tt>):
<lang bash>echo "begin writeLn('Hi'); end." | ifpc /dev/stdin</lang>
<syntaxhighlight lang="bash">echo "begin writeLn('Hi'); end." | ifpc /dev/stdin</syntaxhighlight>


=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==
<lang freebasic>' FB 1.05.0 Win64
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64


Shell "echo For i As Integer = 1 To 10 : Print i : Next > zzz.bas && fbc zzz.bas && zzz"
Shell "echo For i As Integer = 1 To 10 : Print i : Next > zzz.bas && fbc zzz.bas && zzz"
Sleep</lang>
Sleep</syntaxhighlight>


{{out}}
{{out}}
Line 315: Line 315:
The <CODE>-e</CODE> command-line option executes a command or commands and prints its value.
The <CODE>-e</CODE> command-line option executes a command or commands and prints its value.


<lang frink>$ frink -e "factorFlat[2^67-1]"</lang>
<syntaxhighlight lang="frink">$ frink -e "factorFlat[2^67-1]"</syntaxhighlight>


{{out}}
{{out}}
Line 324: Line 324:
=={{header|FutureBasic}}==
=={{header|FutureBasic}}==
This is forcing the issue. FB has much more elegant ways of interacting with the Unix Shell.
This is forcing the issue. FB has much more elegant ways of interacting with the Unix Shell.
<lang futurebasic>
<syntaxhighlight lang="futurebasic">
window 1,,(0,0,160,120):Str255 a:open "Unix",1,"cal 10 2018":do:line input #1,a:print a:until eof(1):close 1:HandleEvents
window 1,,(0,0,160,120):Str255 a:open "Unix",1,"cal 10 2018":do:line input #1,a:print a:until eof(1):close 1:HandleEvents
</syntaxhighlight>
</lang>


Output
Output
Line 341: Line 341:
=={{header|Gambas}}==
=={{header|Gambas}}==
'''[https://gambas-playground.proko.eu/?gist=4385adf6a841435779a7afff3dadb58b Click this link to run this code]'''
'''[https://gambas-playground.proko.eu/?gist=4385adf6a841435779a7afff3dadb58b Click this link to run this code]'''
<lang gambas>Public Sub Main()
<syntaxhighlight lang="gambas">Public Sub Main()
Shell "echo Hello World"
Shell "echo Hello World"


End</lang>
End</syntaxhighlight>
Output:
Output:
<pre>
<pre>
Line 352: Line 352:


=={{header|Gema}}==
=={{header|Gema}}==
<lang bash>$ gema -p '\B=Hello\n@end'
<syntaxhighlight lang="bash">$ gema -p '\B=Hello\n@end'
Hello</lang>
Hello</syntaxhighlight>


=={{header|Go}}==
=={{header|Go}}==
<lang bash>echo 'package main;func main(){println("hlowrld")}'>/tmp/h.go;go run /tmp/h.go</lang>
<syntaxhighlight lang="bash">echo 'package main;func main(){println("hlowrld")}'>/tmp/h.go;go run /tmp/h.go</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 364: Line 364:
=={{header|Groovy}}==
=={{header|Groovy}}==
{{works with|UNIX Shell}}
{{works with|UNIX Shell}}
<lang bash>$ groovysh -q "println 'Hello'"
<syntaxhighlight lang="bash">$ groovysh -q "println 'Hello'"
Hello</lang>
Hello</syntaxhighlight>


{{works with|Windows Command Interpreter}}
{{works with|Windows Command Interpreter}}
<lang cmd>C:\Users\user> groovysh -q "println 'Hello'"
<syntaxhighlight lang="cmd">C:\Users\user> groovysh -q "println 'Hello'"
Hello</lang>
Hello</syntaxhighlight>


=={{header|Haskell}}==
=={{header|Haskell}}==
<lang bash>$ ghc -e 'putStrLn "Hello"'
<syntaxhighlight lang="bash">$ ghc -e 'putStrLn "Hello"'
Hello</lang>
Hello</syntaxhighlight>


=={{header|Huginn}}==
=={{header|Huginn}}==
Result of an expression is printed by default:
Result of an expression is printed by default:
<lang bash>$ huginn -c '"Hello"'</lang>
<syntaxhighlight lang="bash">$ huginn -c '"Hello"'</syntaxhighlight>
Output:
Output:
<pre>"Hello"</pre>
<pre>"Hello"</pre>
Even with an explicit `print` function was used:
Even with an explicit `print` function was used:
<lang bash>$ huginn -c 'print("Hello\n")'</lang>
<syntaxhighlight lang="bash">$ huginn -c 'print("Hello\n")'</syntaxhighlight>
Output:
Output:
<pre>Hello
<pre>Hello
none</pre>
none</pre>
Unless the last expression ended with a semicolon:
Unless the last expression ended with a semicolon:
<lang bash>$ huginn -c 'print("Hello\n");'</lang>
<syntaxhighlight lang="bash">$ huginn -c 'print("Hello\n");'</syntaxhighlight>
Output:
Output:
<pre>Hello</pre>
<pre>Hello</pre>
Line 394: Line 394:
These examples work with posix shells.
These examples work with posix shells.


<lang icon>echo "procedure main();write(\"hello\");end" | icont - -x</lang>
<syntaxhighlight lang="icon">echo "procedure main();write(\"hello\");end" | icont - -x</syntaxhighlight>


<lang unicon>echo "procedure main();write(\"hello world\");end" >hello.icn; unicon hello.icn -x</lang>
<syntaxhighlight lang="unicon">echo "procedure main();write(\"hello world\");end" >hello.icn; unicon hello.icn -x</syntaxhighlight>


=={{header|J}}==
=={{header|J}}==
<lang bash>$ jconsole -js "exit echo 'Hello'"
<syntaxhighlight lang="bash">$ jconsole -js "exit echo 'Hello'"
Hello</lang>
Hello</syntaxhighlight>


That said, note that J interpreters can themselves be thought of as [[wp:Command_shell|command shells]].
That said, note that J interpreters can themselves be thought of as [[wp:Command_shell|command shells]].
Line 408: Line 408:
These three lines work with Bourne Shell (or compatible) or C Shell (or compatible), or bash on Unix/Linux/MacOSX/Windows+cygwin
These three lines work with Bourne Shell (or compatible) or C Shell (or compatible), or bash on Unix/Linux/MacOSX/Windows+cygwin


<lang bash>$ echo 'public class X{public static void main(String[]args){' \
<syntaxhighlight lang="bash">$ echo 'public class X{public static void main(String[]args){' \
> 'System.out.println("Hello Java!");}}' >X.java
> 'System.out.println("Hello Java!");}}' >X.java
$ javac X.java && java X</lang>
$ javac X.java && java X</syntaxhighlight>


A user can also enter this as one (very long) line:
A user can also enter this as one (very long) line:


<lang bash>$ echo 'public class X{public static void main(String[]args){System.out.println("Hello Java!");}}'>X.java;javac X.java&&java X</lang>
<syntaxhighlight lang="bash">$ echo 'public class X{public static void main(String[]args){System.out.println("Hello Java!");}}'>X.java;javac X.java&&java X</syntaxhighlight>


{{works with|MS-DOS}} Compatible Environments (such as [[wp:cmd.exe|cmd.exe]])
{{works with|MS-DOS}} Compatible Environments (such as [[wp:cmd.exe|cmd.exe]])
Works with cmd.exe on Windows (tested on Microsoft Windows XP [Version 5.1.2600])
Works with cmd.exe on Windows (tested on Microsoft Windows XP [Version 5.1.2600])
<lang cmd>C:\>echo public class X{public static void main(String[] args){System.out.println("Hello Java!");}}>X.java&&javac X.java&&java X
<syntaxhighlight lang="cmd">C:\>echo public class X{public static void main(String[] args){System.out.println("Hello Java!");}}>X.java&&javac X.java&&java X
Hello Java!</lang>
Hello Java!</syntaxhighlight>


=={{header|JavaScript}}==
=={{header|JavaScript}}==
{{works with|SpiderMonkey}}
{{works with|SpiderMonkey}}
<lang bash>$ js -e 'print("hello")'
<syntaxhighlight lang="bash">$ js -e 'print("hello")'
hello</lang>
hello</syntaxhighlight>


=={{header|jq}}==
=={{header|jq}}==
<lang sh>$ jq -M -n 1+1
<syntaxhighlight lang="sh">$ jq -M -n 1+1
2</lang>
2</syntaxhighlight>


=={{header|Julia}}==
=={{header|Julia}}==
<lang julia>$ julia -e 'for x in ARGS; println(x); end' foo bar
<syntaxhighlight lang="julia">$ julia -e 'for x in ARGS; println(x); end' foo bar
foo
foo
bar</lang>
bar</syntaxhighlight>


=={{header|K}}==
=={{header|K}}==
{{works with|Kona}}
{{works with|Kona}}
<lang bash>$ k -e "\`0: \"hello\\n\""</lang>
<syntaxhighlight lang="bash">$ k -e "\`0: \"hello\\n\""</syntaxhighlight>


=={{header|Kotlin}}==
=={{header|Kotlin}}==
Line 453: Line 453:
From stdin:
From stdin:


<lang Lasso>echo " 'The date and time is: ' + date " | lasso9 --</lang>
<syntaxhighlight lang="lasso">echo " 'The date and time is: ' + date " | lasso9 --</syntaxhighlight>


Or alternatively:
Or alternatively:


<lang Lasso>$ lasso9 -s " 'The date and time is: ' + date "</lang>
<syntaxhighlight lang="lasso">$ lasso9 -s " 'The date and time is: ' + date "</syntaxhighlight>


=={{header|Liberty BASIC}}==
=={{header|Liberty BASIC}}==
<syntaxhighlight lang="lb">
<lang lb>
echo print "hello">oneLiner.bas & liberty -r oneLiner.bas echo print "hello">oneLiner.bas & liberty -r oneLiner.bas
echo print "hello">oneLiner.bas & liberty -r oneLiner.bas echo print "hello">oneLiner.bas & liberty -r oneLiner.bas
</syntaxhighlight>
</lang>


=={{header|Lua}}==
=={{header|Lua}}==
<lang bash>lua -e 'print "Hello World!"'</lang>
<syntaxhighlight lang="bash">lua -e 'print "Hello World!"'</syntaxhighlight>


=={{header|Maple}}==
=={{header|Maple}}==
<lang bash>maple -c'print(HELLO);' -cquit</lang>
<syntaxhighlight lang="bash">maple -c'print(HELLO);' -cquit</syntaxhighlight>


=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>echo Print[2+2] > file & math.exe -script file</lang>
<syntaxhighlight lang="mathematica">echo Print[2+2] > file & math.exe -script file</syntaxhighlight>


=={{header|min}}==
=={{header|min}}==
<lang min>min -e:"\"hi from min\" puts!"</lang>
<syntaxhighlight lang="min">min -e:"\"hi from min\" puts!"</syntaxhighlight>


=={{header|Nanoquery}}==
=={{header|Nanoquery}}==
<lang bash>nq -e "println \"Hello Nanoquery!\""</lang>
<syntaxhighlight lang="bash">nq -e "println \"Hello Nanoquery!\""</syntaxhighlight>


=={{header|NetLogo}}==
=={{header|NetLogo}}==
Line 483: Line 483:


=== Observer Mode ===
=== Observer Mode ===
<lang NetLogo>let x 15 ask turtles [ set xcor x set x x + 1 ]</lang>
<syntaxhighlight lang="netlogo">let x 15 ask turtles [ set xcor x set x x + 1 ]</syntaxhighlight>


=== Turtle Mode ===
=== Turtle Mode ===
<lang NetLogo>right random 90 forward 10</lang>
<syntaxhighlight lang="netlogo">right random 90 forward 10</syntaxhighlight>


=={{header|NetRexx}}==
=={{header|NetRexx}}==
{{works with|UNIX Shell}}
{{works with|UNIX Shell}}
Create a temporary file, execute the file via the NetRexx interpreter then delete the temporary file and any files generated via the translation. (i.e. Java class files etc.)
Create a temporary file, execute the file via the NetRexx interpreter then delete the temporary file and any files generated via the translation. (i.e. Java class files etc.)
<lang bash>
<syntaxhighlight lang="bash">
$ TNRX=`mktemp T_XXXXXXXXXXXX` && test ! -e $TNRX.* && (echo 'say "Goodbye, World!"' >$TNRX; nrc -exec $TNRX; rm $TNRX $TNRX.*; unset TNRX)
$ TNRX=`mktemp T_XXXXXXXXXXXX` && test ! -e $TNRX.* && (echo 'say "Goodbye, World!"' >$TNRX; nrc -exec $TNRX; rm $TNRX $TNRX.*; unset TNRX)
</syntaxhighlight>
</lang>


'''Output:'''
'''Output:'''
Line 507: Line 507:


=={{header|NewLISP}}==
=={{header|NewLISP}}==
<lang NewLISP>newlisp -e "\"Hello\"
<syntaxhighlight lang="newlisp">newlisp -e "\"Hello\"
->"Hello"</lang>
->"Hello"</syntaxhighlight>


=={{header|Nim}}==
=={{header|Nim}}==
Line 527: Line 527:
=={{header|Objeck}}==
=={{header|Objeck}}==
{{works with|UNIX Shell}}
{{works with|UNIX Shell}}
<lang bash>./obc -run '"Hello"->PrintLine();' -dest hello.obe ; ./obr hello.obe</lang>
<syntaxhighlight lang="bash">./obc -run '"Hello"->PrintLine();' -dest hello.obe ; ./obr hello.obe</syntaxhighlight>


=={{header|OCaml}}==
=={{header|OCaml}}==
<lang bash>$ ocaml <(echo 'print_endline "Hello"')
<syntaxhighlight lang="bash">$ ocaml <(echo 'print_endline "Hello"')
Hello</lang>
Hello</syntaxhighlight>
{{works with|OCaml|4.00+}}
{{works with|OCaml|4.00+}}
<lang bash>$ echo 'print_endline "Hello"' | ocaml -stdin
<syntaxhighlight lang="bash">$ echo 'print_endline "Hello"' | ocaml -stdin
Hello</lang>
Hello</syntaxhighlight>


=={{header|Octave}}==
=={{header|Octave}}==
<lang matlab>$ octave --eval 'printf("Hello World, it is %s!\n",datestr(now));'
<syntaxhighlight lang="matlab">$ octave --eval 'printf("Hello World, it is %s!\n",datestr(now));'
Hello World, it is 28-Aug-2013 17:53:47!</lang>
Hello World, it is 28-Aug-2013 17:53:47!</syntaxhighlight>


=={{header|Oforth}}==
=={{header|Oforth}}==


<lang Oforth>oforth --P"1000 seq map(#sqrt) sum print"</lang>
<syntaxhighlight lang="oforth">oforth --P"1000 seq map(#sqrt) sum print"</syntaxhighlight>


{{out}}
{{out}}
Line 550: Line 550:


=={{header|ooRexx}}==
=={{header|ooRexx}}==
<lang bash>
<syntaxhighlight lang="bash">
rexx -e "say 'Goodbye, world.'"
rexx -e "say 'Goodbye, world.'"
</syntaxhighlight>
</lang>


=={{header|Oz}}==
=={{header|Oz}}==
This is difficult to do in Oz because the compiler/interpreter always wants the source code in a file and does not read from stdin. We can do somethings like this on Unix-like systems:
This is difficult to do in Oz because the compiler/interpreter always wants the source code in a file and does not read from stdin. We can do somethings like this on Unix-like systems:
<lang bash>echo >tmp.oz "{System.show hello}"; ozc -l System -e tmp.oz
<syntaxhighlight lang="bash">echo >tmp.oz "{System.show hello}"; ozc -l System -e tmp.oz
hello</lang>
hello</syntaxhighlight>


With <code>-l System</code> we make the System module available so that we can print something.
With <code>-l System</code> we make the System module available so that we can print something.


=={{header|PARI/GP}}==
=={{header|PARI/GP}}==
<lang bash>echo "print(Pi)" | gp -q</lang>
<syntaxhighlight lang="bash">echo "print(Pi)" | gp -q</syntaxhighlight>


=={{header|Pascal}}==
=={{header|Pascal}}==
Line 568: Line 568:


=={{header|Perl}}==
=={{header|Perl}}==
<lang bash>$ perl -e 'print "Hello\n"'
<syntaxhighlight lang="bash">$ perl -e 'print "Hello\n"'
Hello</lang>
Hello</syntaxhighlight>


More information about the many ways of invoking perl can be found in [http://perldoc.perl.org/perlrun.html perlrun].
More information about the many ways of invoking perl can be found in [http://perldoc.perl.org/perlrun.html perlrun].
Line 586: Line 586:
=={{header|PHP}}==
=={{header|PHP}}==
assuming you have the PHP CLI (command-line interface) installed, not just the web server plugin
assuming you have the PHP CLI (command-line interface) installed, not just the web server plugin
<lang bash>$ php -r 'echo "Hello\n";'
<syntaxhighlight lang="bash">$ php -r 'echo "Hello\n";'
Hello</lang>
Hello</syntaxhighlight>


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
<lang PicoLisp>$ picolisp -'prinl "Hello world!"' -bye
<syntaxhighlight lang="picolisp">$ picolisp -'prinl "Hello world!"' -bye
Hello world!</lang>
Hello world!</syntaxhighlight>


=={{header|Pike}}==
=={{header|Pike}}==
<lang bash>$ pike -e 'write("Hello\n");'
<syntaxhighlight lang="bash">$ pike -e 'write("Hello\n");'
Hello</lang>
Hello</syntaxhighlight>


=={{header|PowerShell}}==
=={{header|PowerShell}}==
<lang cmd>> powershell -Command "Write-Host 'Hello'"
<syntaxhighlight lang="cmd">> powershell -Command "Write-Host 'Hello'"
Hello</lang>
Hello</syntaxhighlight>


=={{header|Processing}}==
=={{header|Processing}}==
Line 605: Line 605:


In bash:
In bash:
<lang Processing>mkdir -p Tmp; echo "println(\"hello world\");" > Tmp/Tmp.pde; processing-java --sketch="`pwd`/Tmp" --run</lang>
<syntaxhighlight lang="processing">mkdir -p Tmp; echo "println(\"hello world\");" > Tmp/Tmp.pde; processing-java --sketch="`pwd`/Tmp" --run</syntaxhighlight>


{{out}}
{{out}}
Line 614: Line 614:
=={{header|Prolog}}==
=={{header|Prolog}}==
===Command-Line Options===
===Command-Line Options===
<lang prolog>$ swipl -g "writeln('hello world')." -t 'halt.'
<syntaxhighlight lang="prolog">$ swipl -g "writeln('hello world')." -t 'halt.'
hello world
hello world
$</lang>
$</syntaxhighlight>
<lang prolog>$ gprolog --init-goal "write('goodbye'),nl,halt"
<syntaxhighlight lang="prolog">$ gprolog --init-goal "write('goodbye'),nl,halt"
goodbye
goodbye
$</lang>
$</syntaxhighlight>
<lang prolog>$ yap -q -g "current_prolog_flag(dialect, D), writeln(D), halt"
<syntaxhighlight lang="prolog">$ yap -q -g "current_prolog_flag(dialect, D), writeln(D), halt"
yap</lang>
yap</syntaxhighlight>
=== <<< ===
=== <<< ===
<lang prolog>$ swipl -q <<< "current_prolog_flag(dialect,D), writeln(D), halt."
<syntaxhighlight lang="prolog">$ swipl -q <<< "current_prolog_flag(dialect,D), writeln(D), halt."
swi
swi


$ yap -q <<< "current_prolog_flag(dialect,D), writeln(D), halt."
$ yap -q <<< "current_prolog_flag(dialect,D), writeln(D), halt."
yap</lang>
yap</syntaxhighlight>
=== Pipe ===
=== Pipe ===
<lang prolog>$ echo "current_prolog_flag(dialect,D), writeln(D), halt." | swipl -q
<syntaxhighlight lang="prolog">$ echo "current_prolog_flag(dialect,D), writeln(D), halt." | swipl -q
swi
swi


$ echo "current_prolog_flag(dialect,D), writeln(D), halt." | yap -q
$ echo "current_prolog_flag(dialect,D), writeln(D), halt." | yap -q
yap</lang>
yap</syntaxhighlight>


=={{header|PureBasic}}==
=={{header|PureBasic}}==
Runs on Linux with(thanks to) bash. Path variables must be set as decribed in INSTALL.
Runs on Linux with(thanks to) bash. Path variables must be set as decribed in INSTALL.
<lang bash>$ echo 'messagerequester("Greetings","hello")' > "dib.pb" && ./pbcompiler dib.pb -e "dib" && ./dib</lang>
<syntaxhighlight lang="bash">$ echo 'messagerequester("Greetings","hello")' > "dib.pb" && ./pbcompiler dib.pb -e "dib" && ./dib</syntaxhighlight>


=={{header|Python}}==
=={{header|Python}}==
===Prints "Hello"===
===Prints "Hello"===
<lang bash>$ python -c 'print "Hello"'
<syntaxhighlight lang="bash">$ python -c 'print "Hello"'
Hello</lang>
Hello</syntaxhighlight>


===Web server with CGI===
===Web server with CGI===
The python CGIHTTPServer module is also an [[Executable library|executable library]] that performs as a web server with CGI. to start enter:
The python CGIHTTPServer module is also an [[Executable library|executable library]] that performs as a web server with CGI. to start enter:
<lang bash>python -m CGIHTTPServer</lang>
<syntaxhighlight lang="bash">python -m CGIHTTPServer</syntaxhighlight>
It returns with:
It returns with:
<pre>Serving HTTP on 0.0.0.0 port 8000 ...</pre>
<pre>Serving HTTP on 0.0.0.0 port 8000 ...</pre>
Line 652: Line 652:
=={{header|Quackery}}==
=={{header|Quackery}}==


<lang bash>$ QUACK=$(mktemp); echo "say 'hello'" > $QUACK; quackery $QUACK; rm $QUACK
<syntaxhighlight lang="bash">$ QUACK=$(mktemp); echo "say 'hello'" > $QUACK; quackery $QUACK; rm $QUACK
hello</lang>
hello</syntaxhighlight>


===Via Python 3===
===Via Python 3===
Line 659: Line 659:
As Quackery is implemented as a Python 3 function, assuming that quackery.py is in the module search path:
As Quackery is implemented as a Python 3 function, assuming that quackery.py is in the module search path:


<lang bash>$ python3 -c 'import quackery ; quackery.quackery(r""" say '\''hello'\'' cr """)'
<syntaxhighlight lang="bash">$ python3 -c 'import quackery ; quackery.quackery(r""" say '\''hello'\'' cr """)'
hello</lang>
hello</syntaxhighlight>


=={{header|R}}==
=={{header|R}}==
<lang bash>$ echo 'cat("Hello\n")' | R --slave
<syntaxhighlight lang="bash">$ echo 'cat("Hello\n")' | R --slave
Hello</lang>
Hello</syntaxhighlight>


Alternatively, using the Rscript front-end,
Alternatively, using the Rscript front-end,
<lang bash>$ Rscript -e 'cat("Hello\n")'
<syntaxhighlight lang="bash">$ Rscript -e 'cat("Hello\n")'
Hello</lang>
Hello</syntaxhighlight>


=={{header|Racket}}==
=={{header|Racket}}==
<lang bash>$ racket -e "(displayln \"Hello World\")"
<syntaxhighlight lang="bash">$ racket -e "(displayln \"Hello World\")"
Hello World</lang>
Hello World</syntaxhighlight>


=={{header|Raku}}==
=={{header|Raku}}==
Line 678: Line 678:
{{works with|Rakudo|#22 "Thousand Oaks"}}
{{works with|Rakudo|#22 "Thousand Oaks"}}


<lang bash>$ raku -e 'say "Hello, world!"'
<syntaxhighlight lang="bash">$ raku -e 'say "Hello, world!"'
Hello, world!</lang>
Hello, world!</syntaxhighlight>


=={{header|REBOL}}==
=={{header|REBOL}}==
<lang bash>rebview -vswq --do "print {Hello!} quit" </lang>
<syntaxhighlight lang="bash">rebview -vswq --do "print {Hello!} quit" </syntaxhighlight>


Output:
Output:
Line 688: Line 688:


=={{header|Retro}}==
=={{header|Retro}}==
<lang Retro>echo '\'hello s:put nl bye' | retro</lang>
<syntaxhighlight lang="retro">echo '\'hello s:put nl bye' | retro</syntaxhighlight>


=={{header|REXX}}==
=={{header|REXX}}==
Note: &nbsp; Regina REXX is the only version of REXX that supports this type of behavior &nbsp; (taking it's input from a console stream).
Note: &nbsp; Regina REXX is the only version of REXX that supports this type of behavior &nbsp; (taking it's input from a console stream).
<lang rexx>
<syntaxhighlight lang="rexx">
╔══════════════════════════════════════════════╗
╔══════════════════════════════════════════════╗
║ ║
║ ║
Line 700: Line 700:




echo do j=10 by 20 for 4; say right('hello',j); end | regina</lang>
echo do j=10 by 20 for 4; say right('hello',j); end | regina</syntaxhighlight>
'''output''' &nbsp; when entering the (above) from the (DOS) command line:
'''output''' &nbsp; when entering the (above) from the (DOS) command line:
<pre>
<pre>
Line 710: Line 710:


=={{header|Ring}}==
=={{header|Ring}}==
<lang ring>
<syntaxhighlight lang="ring">
see "Hello World!" + nl
see "Hello World!" + nl
</syntaxhighlight>
</lang>
Output:
Output:
<pre>
<pre>
Line 720: Line 720:
=={{header|Ruby}}==
=={{header|Ruby}}==
From [[Unix]]:
From [[Unix]]:
<lang bash>$ ruby -e 'puts "Hello"'
<syntaxhighlight lang="bash">$ ruby -e 'puts "Hello"'
Hello</lang>
Hello</syntaxhighlight>


{{works with|JRuby}}
{{works with|JRuby}}
<lang bash>$ jruby -e 'puts "Hello from JRuby"'
<syntaxhighlight lang="bash">$ jruby -e 'puts "Hello from JRuby"'
Hello from JRuby</lang>
Hello from JRuby</syntaxhighlight>


{{works with|Rubinius}}
{{works with|Rubinius}}
<lang bash>$ rbx -e 'puts "Hello from Rubinius"'
<syntaxhighlight lang="bash">$ rbx -e 'puts "Hello from Rubinius"'
Hello from Rubinius</lang>
Hello from Rubinius</syntaxhighlight>


=={{header|Run BASIC}}==
=={{header|Run BASIC}}==
<lang bash>print shell$("echo hello world")</lang>
<syntaxhighlight lang="bash">print shell$("echo hello world")</syntaxhighlight>


=={{header|Rust}}==
=={{header|Rust}}==
Line 738: Line 738:
delete it to avoid to call another shell/system dependent command/program). The
delete it to avoid to call another shell/system dependent command/program). The
''current directory'' is not specified by <tt>./</tt> in every system...
''current directory'' is not specified by <tt>./</tt> in every system...
<lang bash>$ echo 'fn main(){println!("Hello!")}' | rustc -;./rust_out</lang>
<syntaxhighlight lang="bash">$ echo 'fn main(){println!("Hello!")}' | rustc -;./rust_out</syntaxhighlight>


=={{header|S-lang}}==
=={{header|S-lang}}==
<lang S-lang>slsh -e 'print("Hello, World")'</lang>
<syntaxhighlight lang="s-lang">slsh -e 'print("Hello, World")'</syntaxhighlight>


Or, in MSW cmd.exe:
Or, in MSW cmd.exe:


<lang S-lang>slsh -e "print(\"Hello, World\")"</lang>
<syntaxhighlight lang="s-lang">slsh -e "print(\"Hello, World\")"</syntaxhighlight>


Note that print() is included w/slsh, but is not part of S-Lang itself.
Note that print() is included w/slsh, but is not part of S-Lang itself.
Line 751: Line 751:
=={{header|Scala}}==
=={{header|Scala}}==
{{libheader|Scala}}
{{libheader|Scala}}
<lang cmd>C:\>scala -e "println(\"Hello\")"
<syntaxhighlight lang="cmd">C:\>scala -e "println(\"Hello\")"
Hello</lang>
Hello</syntaxhighlight>
<lang cmd>
<syntaxhighlight lang="cmd">
PS C:\> scala -e 'println(\"Hello\")'
PS C:\> scala -e 'println(\"Hello\")'
Hello</lang>
Hello</syntaxhighlight>


The escaping of quotes is required by Windows.
The escaping of quotes is required by Windows.
Line 763: Line 763:
=={{header|Scheme}}==
=={{header|Scheme}}==
{{works with|Guile}}
{{works with|Guile}}
<lang scheme>guile -c '(display "Hello, world!\n")'</lang>
<syntaxhighlight lang="scheme">guile -c '(display "Hello, world!\n")'</syntaxhighlight>


=={{header|Shiny}}==
=={{header|Shiny}}==
<lang shiny>shiny -e "say 'hi'" </lang>
<syntaxhighlight lang="shiny">shiny -e "say 'hi'" </syntaxhighlight>


=={{header|Sidef}}==
=={{header|Sidef}}==
<lang ruby>% sidef -E "say 'hello'"</lang>
<syntaxhighlight lang="ruby">% sidef -E "say 'hello'"</syntaxhighlight>


=={{header|Slate}}==
=={{header|Slate}}==
<lang slate>./slate --eval "[inform: 'hello'] ensure: [exit: 0].".</lang>
<syntaxhighlight lang="slate">./slate --eval "[inform: 'hello'] ensure: [exit: 0].".</syntaxhighlight>


=={{header|SNOBOL4}}==
=={{header|SNOBOL4}}==
Portable version
Portable version
<lang snobol>echo 'a output = "Hello, World!";end' | snobol4 -b</lang>
<syntaxhighlight lang="snobol">echo 'a output = "Hello, World!";end' | snobol4 -b</syntaxhighlight>


Bash version
Bash version
<lang snobol>snobol4 -b <<<'a output = "Hello, World!";end'</lang>
<syntaxhighlight lang="snobol">snobol4 -b <<<'a output = "Hello, World!";end'</syntaxhighlight>


=={{header|Tcl}}==
=={{header|Tcl}}==
This is an area where Tcl is lacking, though when shell one-liners are required a construct like this is typically used:
This is an area where Tcl is lacking, though when shell one-liners are required a construct like this is typically used:
<lang bash>$ echo 'puts Hello' | tclsh
<syntaxhighlight lang="bash">$ echo 'puts Hello' | tclsh
Hello</lang>
Hello</syntaxhighlight>


=={{header|TXR}}==
=={{header|TXR}}==


<lang bash>$ echo 123-456-7890 | txr -c '@a-@b-@c' -
<syntaxhighlight lang="bash">$ echo 123-456-7890 | txr -c '@a-@b-@c' -
a="123"
a="123"
b="456"
b="456"
c="7890"
c="7890"
</syntaxhighlight>
</lang>


Most useful txr queries consist of multiple lines, and the line structure is important. Multi-liners can be passed via <code>-c</code> easily, but there is no provision in the syntax that would allow multi-liners to be actually written as one physical line. There are opposite provisions for splitting long logical lines into multiple physical lines.
Most useful txr queries consist of multiple lines, and the line structure is important. Multi-liners can be passed via <code>-c</code> easily, but there is no provision in the syntax that would allow multi-liners to be actually written as one physical line. There are opposite provisions for splitting long logical lines into multiple physical lines.
Line 799: Line 799:
TXR Lisp:
TXR Lisp:


<lang bash>$ txr -p '(+ 2 2)'
<syntaxhighlight lang="bash">$ txr -p '(+ 2 2)'
4</lang>
4</syntaxhighlight>


<lang bash>$ txr -e '(mkdir "foo" #o777)'
<syntaxhighlight lang="bash">$ txr -e '(mkdir "foo" #o777)'
$ ls -ld foo
$ ls -ld foo
drwxrwxr-x 2 kaz kaz 4096 Mar 4 23:36 foo</lang>
drwxrwxr-x 2 kaz kaz 4096 Mar 4 23:36 foo</syntaxhighlight>


=={{header|UNIX Shell}}==
=={{header|UNIX Shell}}==
Explicit call of the shell, passing the shell command via the <code>-c</code> option:
Explicit call of the shell, passing the shell command via the <code>-c</code> option:
<lang bash>$ sh -c ls</lang>
<syntaxhighlight lang="bash">$ sh -c ls</syntaxhighlight>
<lang bash>$ sh -c "echo hello"</lang>
<syntaxhighlight lang="bash">$ sh -c "echo hello"</syntaxhighlight>


To invoke a specific shell like [[Bash]], [[Korn Shell]] or [[Z Shell]]:
To invoke a specific shell like [[Bash]], [[Korn Shell]] or [[Z Shell]]:


<lang bash>$ bash -c 'paste <(echo 1) <(echo 2)'
<syntaxhighlight lang="bash">$ bash -c 'paste <(echo 1) <(echo 2)'
$ ksh -c 'let i=3+4; print $i'
$ ksh -c 'let i=3+4; print $i'
$ zsh -c 'if [[ 5 -lt 6 ]] { echo ok };'</lang>
$ zsh -c 'if [[ 5 -lt 6 ]] { echo ok };'</syntaxhighlight>


Shell scripts almost never use <code>sh -c</code>, because there are various implicit ways whereby the shell command language evaluates a command in a subshell:
Shell scripts almost never use <code>sh -c</code>, because there are various implicit ways whereby the shell command language evaluates a command in a subshell:


<lang bash>$ VAR=`echo hello` # obsolescent backtick notation
<syntaxhighlight lang="bash">$ VAR=`echo hello` # obsolescent backtick notation
$ VAR=$(echo hello) # modern POSIX notation
$ VAR=$(echo hello) # modern POSIX notation
$ (echo hello) # execute in another shell process, not in this one</lang>
$ (echo hello) # execute in another shell process, not in this one</syntaxhighlight>


There are more details about <code>`echo hello`</code> and <code>$(echo hello)</code> at [[Execute a system command#UNIX Shell]].
There are more details about <code>`echo hello`</code> and <code>$(echo hello)</code> at [[Execute a system command#UNIX Shell]].
Line 828: Line 828:
Run a C shell command from any shell:
Run a C shell command from any shell:


<lang bash>$ csh -fc 'if (5 < 6) echo ok'</lang>
<syntaxhighlight lang="bash">$ csh -fc 'if (5 < 6) echo ok'</syntaxhighlight>


==={{header|es}}===
==={{header|es}}===
Run a command, in extensible shell, from any shell:
Run a command, in extensible shell, from any shell:


<lang bash>$ es -c 'if {test 5 -lt 6} {echo ok}'</lang>
<syntaxhighlight lang="bash">$ es -c 'if {test 5 -lt 6} {echo ok}'</syntaxhighlight>


=={{header|Ursala}}==
=={{header|Ursala}}==
The command to execute the Ursala compiler is fun. An expression supplied as a parameter to the --main option is compiled and evaluated. If the expression evaluates to a list of character strings, it can be displayed on standard output with --show. If it's some other type, it can be formatted for display by --cast <type expression>,
The command to execute the Ursala compiler is fun. An expression supplied as a parameter to the --main option is compiled and evaluated. If the expression evaluates to a list of character strings, it can be displayed on standard output with --show. If it's some other type, it can be formatted for display by --cast <type expression>,


<lang bash>$ fun --main=-[hello]- --show
<syntaxhighlight lang="bash">$ fun --main=-[hello]- --show
hello
hello
$ fun --main="power/2 32" --cast %n
$ fun --main="power/2 32" --cast %n
4294967296
4294967296
$ fun --m="..mp2str mpfr..pi 120" --c %s
$ fun --m="..mp2str mpfr..pi 120" --c %s
'3.1415926535897932384626433832795028847E+00'</lang>
'3.1415926535897932384626433832795028847E+00'</syntaxhighlight>


=={{header|Vedit macro language}}==
=={{header|Vedit macro language}}==
The following DOS command starts Vedit and displays a message.
The following DOS command starts Vedit and displays a message.
When the user presses any key, Vedit exits.
When the user presses any key, Vedit exits.
<lang cmd>vpw -c'Get_Key("Hello!") exit'</lang>
<syntaxhighlight lang="cmd">vpw -c'Get_Key("Hello!") exit'</syntaxhighlight>


=={{header|Wart}}==
=={{header|Wart}}==
<lang bash>echo "prn 34" |wart</lang>
<syntaxhighlight lang="bash">echo "prn 34" |wart</syntaxhighlight>


=={{header|Wren}}==
=={{header|Wren}}==
<lang bash>echo 'System.print("Hello from Wren!")' > tmp.wren; wren tmp.wren</lang>
<syntaxhighlight lang="bash">echo 'System.print("Hello from Wren!")' > tmp.wren; wren tmp.wren</syntaxhighlight>


{{out}}
{{out}}
Line 863: Line 863:
=={{header|zkl}}==
=={{header|zkl}}==
With a unix like shell, just pipe the program into the REPL. Kinda greasy and noisy. To shut it up, send stdout to /dev/null
With a unix like shell, just pipe the program into the REPL. Kinda greasy and noisy. To shut it up, send stdout to /dev/null
<lang bash>echo 'println("Hello World ",5+6)' | zkl</lang>
<syntaxhighlight lang="bash">echo 'println("Hello World ",5+6)' | zkl</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>