$cat u.txt UPPERCASE $cat l.txt cat: l.txt: No such file or directory $tr A-Z a-z l.txt $cat u.txt UPPERCASE $cat l.txt uppercase $
sample session related to “command expansion” in Bash shell
$a=`time` real 0m0.000s user 0m0.000s sys 0m0.000s $a bash: a: command not found $a=`ls` $a bash: a: command not found $echo a a $echo $a a.txt b.txt trueangle $echo `a` bash: a: command not found $a=`ls` $b=time $echo $b time $b=`time` real 0m0.000s user 0m0.000s sys 0m0.000s $echo $b $b=`time` real 0m0.000s user 0m0.000s sys 0m0.000s $echo $b $b=date $echo $b date $b=`date` $echo $b Fri Apr 22 22:50:27 IST 2016 $ http://mywiki.wooledge.org/BashFAQ/032
using the dir() Built-in function in Python programming
>>> import struct
>>> dir() # show the names in the module namespace
['__builtins__', '__doc__', '__name__', 'struct']
>>> dir(struct) # show the names in the struct module
['Struct', '__builtins__', '__doc__', '__file__', '__name__',
'__package__', '_clearcache', 'calcsize', 'error', 'pack', 'pack_into',
'unpack', 'unpack_from']
>>> class Shape(object):
def __dir__(self):
return ['area', 'perimeter', 'location']
>>> s = Shape()
>>> dir(s)
['area', 'perimeter', 'location']
https://docs.python.org/2/library/functions.html#dir
sample session using “variable expansion” with Bash shell
$com=world
$echo com
com
$echo $com
world
$x=hello
$echo ${x}{com}
hello{com}
$echo ${x}${com}
helloworld
$echo $x$com
helloworld
$echo ${x}world
helloworld
$echo ${x} world
hello world
$echo $x world
hello world
$echo $xcom
$echo $x com
hello com
$echo $x $com
hello world
$echo $x$com
helloworld
$echo $xcom
$echo ${x}com
hellocom
$
$your_id=${USER}-on-${HOSTNAME}
$echo "$your_id"
jeffrin-on-debian
$your_id=$USER-on-$HOSTNAME
$echo "$your_id"
jeffrin-on-debian
$echo ${USER}5
jeffrin5
$echo $USER5
$echo $USER 5
jeffrin 5
$echo $USER 5
jeffrin 5
$your_id=hello
$echo $your_id5
$echo $your_id 5
hello 5
$echo ${your_id}5
hello5
$
http://www.tldp.org/LDP/abs/html/parameter-substitution.html
http://guide.bash.academy/03.variables.html
what is a nondeterministic algorithm ?
In computer science, a nondeterministic algorithm is an algorithm that, even for the same input, can exhibit different behaviors on different runs, as opposed to a deterministic algorithm. https://en.wikipedia.org/wiki/Nondeterministic_algorithm
sample session about “brace and tilde” expansions in Bash
$ls
trueangle
$echo hello > a.txt
$echo killo > b.txt
$cat {a,b}.txt
hello
killo
$pwd
/home/jeffrin/temp
$cd ~
$pwd
/home/jeffrin
$cd tr
trueangle/ trueangle.old/
$pwd
/home/jeffrin
$cd -
/home/jeffrin/temp
$pwd
/home/jeffrin/temp
$ls
a.txt b.txt trueangle
$
sample session about “alias expansion” in Bash
$ls -l 1 ls: cannot access '1': No such file or directory $cat >> 1 hello $ls -l 1 -rw-r--r-- 1 jeffrin jeffrin 6 Mar 20 23:38 1 $cat 1 hello $alias appendinput="cat >>" $appendinput bash: syntax error near unexpected token `newline' $appendinput app added $cat app added $
sample session with a bash shell expansion named “history expansion”
$! 1 bash: 1: command not found $!1 bash: !1: event not found $!+1 bash: !+1: event not found $!-1 ! 1 bash: 1: command not found $!! ! 1 bash: 1: command not found $!-0 bash: !-0: event not found $
getting choices listed directly with the first TAB
$p Display all 428 possibilities? (y or n) $p bash: p: command not found $cat .inputrc set show-all-if-ambiguous on $ related text: Specifies the duration Readline will wait for a character when reading an ambiguous key sequence (one that can form a complete key sequence using the input read so far, or can take additional input to complete a longer key sequence).
enclose one or more commands inside a pair of parentheses
$ls
1
$( ls date )
ls: cannot access date: No such file or directory
$( `ls` date )
bash: 1: command not found
$cat 1
B$
$( ls `date` )
ls: cannot access Mon: No such file or directory
ls: cannot access Feb: No such file or directory
ls: cannot access 22: No such file or directory
ls: cannot access 21:36:34: No such file or directory
ls: cannot access IST: No such file or directory
ls: cannot access 2016: No such file or directory
$( `ls` `date` )
bash: 1: command not found
$( ls time )
ls: cannot access time: No such file or directory
$( ls `time` )
real 0m0.000s
user 0m0.000s
sys 0m0.000s
1
$( ls pwd )
ls: cannot access pwd: No such file or directory
$ls pwd
ls: cannot access pwd: No such file or directory
$( ls ) ( pwd )
bash: syntax error near unexpected token `('
$ls date
ls: cannot access date: No such file or directory
$`ls` date
bash: 1: command not found
$ls `date`
ls: cannot access Mon: No such file or directory
ls: cannot access Feb: No such file or directory
ls: cannot access 22: No such file or directory
ls: cannot access 21:41:17: No such file or directory
ls: cannot access IST: No such file or directory
ls: cannot access 2016: No such file or directory
$ (ls pwd )
ls: cannot access pwd: No such file or directory
$x =1
bash: x: command not found
$x = 1
bash: x: command not found
$$x = 1
bash: =: command not found
$ (x = 1)
bash: x: command not found
$x=1
$echo $x
1
$(echo $x)
1
$echo $x
1
$(x=2;echo $x)
2
$echo $x
1
$(x=2 echo $x)
1
$echo $x
1
$(x=2;echo $x)
2
$
http://www.tldp.org/LDP/abs/html/subshells.html
http://unix.stackexchange.com/questions/138463/do-parentheses-really-put-the-command-in-a-subshell