Erlang Tinkering

ABOUT ERLANG

Erlang (/ˈɜːrlæŋ/ UR-lang) is a general-purpose, concurrent, functional programming language, as well as a garbage-collected runtime system.

The term Erlang is used interchangeably with Erlang/OTP, or OTP, which consists of the Erlang runtime system, a number of ready-to-use components mainly written in Erlang, and a set of design principles for Erlang programs.[3]

The Erlang runtime system is known for its designs that are well suited for systems with the following characteristics:

Distributed
Fault-tolerant
Soft real-time
Highly available, non-stop applications
Hot swapping, where code can be changed without stopping a system.[4]
The Erlang programming language is known for the following properties:[5]

Immutable data
Pattern matching
Functional programming

TYPICAL COMMANDLINE SESSION
[bash]
$erl
[/bash]
TYPICAL ERLANG SHELL RELATED
[erlang]
Eshell V5.10.1 (abort with ^G)
1> q().
ok
2> $erl
Erlang R16B (erts-5.10.1) [source] [64-bit] [async-threads:10] [kernel-poll:false]

Eshell V5.10.1 (abort with ^G)
1> q()
1>
1> .
ok
2> $erl
Erlang R16B (erts-5.10.1) [source] [64-bit] [async-threads:10] [kernel-poll:false]

Eshell V5.10.1 (abort with ^G)
1> 10
1> .
10
2> 23.
23
3> 2#000000
3> .
0
4> 2#111111.
63
5> 8#111111.
37449
6> 16#111111.
1118481
7> 16#jeffrin
* 1: illegal integer
7> 2#jeffrin
* 1: illegal integer
7> 2#jeffrin.
* 1: illegal integer
7> 2#j
* 1: illegal integer
7> 2#cafe
* 1: illegal integer
7>
[/erlang]
LINK
https://en.wikipedia.org/wiki/Erlang_(programming_language)

Testing For File Charactereristics

commandline session

$cat test.sh
#!/usr/bin/env bash
# cookbook filename: checkfile
#
DIRPLACE=/tmp
INFILE=/home/jeffrin/amazing.data
OUTFILE=/home/jeffrin/more.results
if [ -d "$DIRPLACE" ]
then
cd $DIRPLACE
if [ -e "$INFILE" ]
then
if [ -w "$OUTFILE" ]
then
doscience > "$OUTFILE"
else
echo "can not write to $OUTFILE"
fi
else
echo "can not read from $INFILE"
fi
else
echo "can not cd into $DIRPLACE"
fi

$sh test.sh
can not read from /home/jeffrin/amazing.data
$> /home/jeffrin/amazing.data
$sh test.sh
can not write to /home/jeffrin/more.results
$> /home/jeffrin/more.results
$sh test.sh
test.sh: 14: test.sh: doscience: not found
$

related source : Bash CookBook

Bash . Running Several Commands All at Once

commandline session

$ls
src  war
$cd & ls &
[1] 2587
[2] 2588
$src  war

[1]-  Done                    cd
[2]+  Done                    ls --color=auto
$pwd
/home/jeffrin/beautiful-work
$
$cd & ls & cd &
[1] 2590
[2] 2591
[3] 2592
$src  war

[1]   Done                    cd
[2]-  Done                    ls --color=auto
[3]+  Done                    cd
$pwd
/home/jeffrin/beautiful-work
$cd .. & pwd  &
[1] 2593
[2] 2594
$/home/jeffrin/beautiful-work

[1]-  Done                    cd ..
[2]+  Done                    pwd
$pwd
/home/jeffrin/beautiful-work
$cd &
[1] 2614
$pwd
/home/jeffrin/beautiful-work
[1]+  Done                    cd
$ls & cd ; pwd
[1] 2625
/home/jeffrin
$src  war

[1]+  Done                    ls --color=auto  (wd: ~/beautiful-work)
(wd now: ~)
$pwd
/home/jeffrin
$

Basic tinkering with “set” command and “noclobber” related

commandline session

[bash light=”true”]
$echo improve > clean.txt
$cat clean.txt
improve
$set -o noclobber
$echo new > clean.txt
bash: clean.txt: cannot overwrite existing file
$echo new >> clean.txt
$cat clean.txt
improve
new
$echo again >| clean.txt
$cat clean.txt
again
$set +o noclobber
$echo improve > clean.txt
$cat clean.txt
improve
$
[/bash]