J2E50

                            Learn your lessons well:
                            Принеси -- посмотрю..

## PROBLEMS FOR TODAY:

  0. permissions for the first nfs mount (/home/nfs). Solved:
  
    On client:
    
      # umount /mnt/nfs/home/nfs
      # chmod 777 -R /mnt/nfs/home/nfs
      # mount -t nfs 10.0.10.1:/home/nfs /mnt/nfs/home/nfs
      
    also notice that:
    
      # cat /etc/passwd | grep nobody
      nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
      # cat /etc/group | grep nogroup
      nogroup:x:65534:

    fields in /etc/passwd

      username:password:UID:GID:UID_info:home:shell

    fields in /etc/group

      groupname:group_password:GID:[IU1,..IU2]
      
    where IU means invited username.
    
  1. nano: do not paste big data using nano/putty. Solved:
  
    use ed for such purposes.
    
  2. Bash -- religious wars. An explosion of angry comments. Solved:
  
    learn modern sh subset. write lint.
    
  3. nano -- colorized #!/bin/bash. Solved:
  
    By default color syntax highlighting is enabled on my system.
    Clicking ALT+Y disables this [6].
  
  4. extending -- add missing features to consistent set making it poisoned. Solved:
  
      a=a
      echo "${a}bcd" vs echo -e "$a \bbcd"
    
    See Tim Toady discussion below.
  
  5. Perl programming motto. Solved:
  
    https://en.wikipedia.org/wiki/There%27s_more_than_one_way_to_do_it
    pronounced Tim Toady
    
  6. Unary operations in RPN. Solved:
  
     Postfix notation for unary operators, e.g. i++ [5]


## SH. BEFORE..

  String Type. 
  
  "" -- Weak quotes, 
  '' -- Strong quotes, 
  `` -- Command substitution
  
  Escaping:
  
  Escape sequence / Hex value in ASCII / Character represented

  \b  08  Backspace
  \n  0A  Newline (Line Feed)
  \r  0D  Carriage Return
  \t  09  Horizontal Tab
  \\  5C  Backslash
  \nnn    Byte as Octal
  
  Regular expressions metasymbols
  
  |  .  ? * +  [] () {}  ^ $ 

to Tim Toady

  Positional switch: Greedy (default) Lazy '?' Posessive '+'
  
  poisoning example
  
  i. Henry Spenser:
  
    always greedy 
  
  ii. Perl:
  
    greedy lazy   
  
  iii. today [2]:
  
    greedy     ahne, жадный   
    docile     kuulekas, послушный
    lazy       laisk, ленивый
    helpful    kasulik, полезный  
    posessive  valdav, преобладающий

# Classical sh approach:

  concatenate "HAL""0"
  
  expr:     arithmetics +-*/
  test:     -lt -le -eq -ge -gt
  set:      file existance and it's properties [3]
  bitwise:  external program ( bc [7] )
           

# Modern approach -- Arithmetic Expansion:

  Inspired by Perl motto. Supported by modern #!/bin/sh:
  
  (6)  math   :  +  -  *  /  %  **
  (6)  bitwise:  &  |  ^  ~  >> << 
  (3)  logic* :  !  && ||
  (5)  compare:  <  <= == >= >
  (1)  trinity:  ?:
  
  0x.., 
  *) true is 1 false is 0, 
  2's complement ~13 = -14
  
Examples:

  $ echo $((2**3))
  8
  $ echo $((5%3))
  2
  $ echo $(((2<3)+(2>3)))
  1
  $ echo $((1?2:3))
  2
  $ echo $((0?2:3))
  3
  
Limitations: floating point calculations

  $ echo 'print $(( 1./3 ))' | zsh
  0.33333333333333331
    
# RPN

Postfix notation for unary operators, e.g. i++ [5]
  
RPN Example:

Single operand assembly with accumulator stack:
  
  PU PO
  +  -  *  /  %  **
  &  |  ^  ~  >> << 
  !  && ||
  <  <= == >= >
  ?:
  
*) PU -- push
   PO -- pop
   
Example.

   ?: n

works like:
  
   IF (n) THEN
     POP
   ELSE
     POP
     POP
   ENDIF


## USED LINKS
  
1. http://www.grymoire.com/Unix/

2. https://www.rexegg.com/regex-quantifiers.html

3. https://stackoverflow.com/-questions/638975
    /how-do-i-tell-if-a-regular-file-does-not-exist-in-bash
    
4. http://gri.sourceforge.net/

5. https://www.cs.fsu.edu/~engelen/courses/COP402003/notes6.html

6. https://stackoverflow.com/questions/13205254
     /how-to-turn-off-or-at-least-override-syntax-
     highlighting-in-nano-via-nanorc
     
7. https://stackoverflow.com/questions/2954003/bitwise-operations-in-bc


# DRAFT

https://habr.com/en/company/ruvds/blog/326328/

  Bash-скрипты: начало
  Bash-скрипты, часть 2: циклы
  Bash-скрипты, часть 3: параметры и ключи командной строки
  Bash-скрипты, часть 4: ввод и вывод
  Bash-скрипты, часть 5: сигналы, фоновые задачи, управление сценариями
  Bash-скрипты, часть 6: функции и разработка библиотек
  Bash-скрипты, часть 7: sed и обработка текстов
  Bash-скрипты, часть 8: язык обработки данных awk
  Bash-скрипты, часть 9: регулярные выражения
  Bash-скрипты, часть 10: практические примеры
  Bash-скрипты, часть 11: expect и автоматизация интерактивных утилит
    
Все интересное -- в комментариях.

  https://habr.com/en/post/47163/
  https://habr.com/en/post/52871/
