$ cat zzz
#!/bin/bash
/usr/bin/tail +4 "$0" | julia
exit
println("hello world from a bash script")
versioninfo()
Dont forget to
$ chmod u+x zzz
Sample run
$ ./zzz
hello world from a bash script
Julia Version 1.2.0
Commit c6da87ff4b (2019-08-20 00:03 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin18.6.0)
CPU: Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, nehalem)
$ which julia
/usr/local/bin/julia
$ ls -l /usr/local/bin/julia
lrwxr-xr-x 1 ssiew admin 62 23 Aug 18:42 /usr/local/bin/julia -> /Applications/Julia-1.2.app/Contents/Resources/julia/bin/julia
#!/bin/bash
#=
exec julia --color=yes --startup-file=no -e 'include(popfirst!(ARGS))' \
"${BASH_SOURCE[0]}" "$@"
=#
@show ARGS # put any Julia code here
Can we please sticky this thread somewhere or write up these tricks in some docs… I needed this last year at my last job really bad. Also one of the sexiest selling points of Julia to linux users is it’s Bash interop.