BASH CLI Scripting - Paiet/Tech-Journal-for-Everything GitHub Wiki

  • What is BASH?
    • Bourne Again SHell
    • bashing together features of sh, csh, and ksh
    • Created by Brian Fox in 1989 to replace the Bourne Shell
    • Free BASH book: man bash or info bash
    • Bash is a shell
      • What is a shell
        • A shell is a program that allow interaction with the OS
        • aka Command Line Interpreter
      • Interactive logon vs. interactive non-logon vs. non-interactive
        • Interactive logon: Start the computer, greeted with a non-graphical, text-based logon prompt. After logon, you are still in a text-based environment
        • Interactive non-logon: You start a shell by invoking it from the CLI, you start a shell by clicking an icon in the GUI, you don't provide logon credentials in either case
        • Non-Interactive: Runs without user interaction. I.E. startup scripts, init.d, rc.d, etc...
    • Bash compared to other shells
      • sh
      • ksh
      • csh
      • tcsh
      • dash
      • zsh
      • rbash or restricted bash
        • rbash in Debian and bash -r in Redhat
        • man rbash in Debian and man bash then search for RESTRICTED in RH
        • invoke rbash and see what it's like to have it restrict you
      • cygwin (POSIX compliant Windows port)
    • Bash is a scripting and programming language
      • Traditional programming languages are compiled and then run
      • Scripting is using a programming language that is interpreted as it is run with no need to compile it
      • Portability
        • Contains features than the traditional Bourne shell doesn't
          • BASH built-ins
          • Brace expansion
          • Extended test construction
    • Also performs arithmetic
      • Has the ability to calculate numbers
        • This can be helpful at predicting numerical output in scripts
          • The file is 10kb today, it is growing by 2kb per day, how big will the file be in 10 days? If file reaches xKB in size then perform command y