FreeKB - Bash (Scripting) articles
Bash (Scripting) articles

Command Line Options and FlagsCommand line options flags arguments (case statement)shift command line optionscronCreate a crontab entry in bash scriptEmailSend a daily email (cron)FilesCreate Excel or CSV fileFunctionsGetting Started with functionsif elif else thenif, elif, else, then statementsIFS (Internal Field Separator)IFS (Internal Field Separator)JSONParse JSON (python)ListsGetting Started with ListsAppend values to an list (+=)Combining listsCount values in a listGet the first element from a ListGet the last element from a ListRemoving duplicate values from a listSorting ListsLoopsfor loopsMove onto next value in a loop (continue)select loopswhile loopsMathAddition and Increment (+)DivisionMultiplicationSubtractionPrintingprinting bold textRegular ExpressionsAdd a leading zero to single digit numbers in Linuxappend new lines to a file or variablecarriage returns (\r ^M)do something empty lines (sed)do something every nth matchdo something every other matchdo something first all or last matchdo something forward slashesdo something match does/doesn't begin with patterndo something match does/doesn't end with patterndo something pattern matchdo something range matchgrep previous or next matchinline text (paste command)new lines \n and carriage returns \rreplace string in fileReplacing whitespaceuppercase or lowercase (tr command)wildcard characterScript interpreterUnderstanding script interpreterSSHGetting Started with SSHTroubleshootingResolve "unary operator expected"Variablesappend values to a variable (+=)join lines in a variablejoin lines in different variableslocal and remote variables with SSHremove duplicate values from a variableremove new lines from a variablereplace values in a variable