pure-bash-bible
dylan
Merge pull request #106 from pipefail/master
5 лет назад
dylan
Merge pull request #106 from pipefail/master
5 лет назад
Table of ContentsFOREWORDSTRINGSTrim leading and trailing white-space from stringTrim all white-space from string and truncate spacesUse regex on a stringSplit a string on a delimiterChange a string to lowercaseChange a string to uppercaseReverse a string caseTrim quotes from a stringStrip all instances of pattern from stringStrip first occurrence of pattern from stringStrip pattern from start of stringStrip pattern from end of stringPercent-encode a stringDecode a percent-encoded stringCheck if string contains a sub-stringCheck if string starts with sub-stringCheck if string ends with sub-stringARRAYSReverse an arrayRemove duplicate array elementsRandom array elementCycle through an arrayToggle between two valuesLOOPSLoop over a range of numbersLoop over a variable range of numbersLoop over an arrayLoop over an array with an indexLoop over the contents of a fileLoop over files and directoriesFILE HANDLINGRead a file to a stringRead a file to an array (by line)Get the first N lines of a fileGet the last N lines of a fileGet the number of lines in a fileCount files or directories in directoryCreate an empty fileExtract lines between two markersFILE PATHSGet the directory name of a file pathGet the base-name of a file pathVARIABLESAssign and access a variable using a variableName a variable based on another variableESCAPE SEQUENCESText ColorsText AttributesCursor MovementErasing TextPARAMETER EXPANSIONIndirectionReplacementLengthExpansionCase ModificationDefault ValueBRACE EXPANSIONRangesString ListsCONDITIONAL EXPRESSIONSFile ConditionalsFile ComparisonsVariable ConditionalsVariable ComparisonsARITHMETIC OPERATORSAssignmentArithmeticBitwiseLogicalMiscellaneousARITHMETICSimpler syntax to set variablesTernary TestsTRAPSDo something on script exitIgnore terminal interrupt (CTRL+C, SIGINT)React to window resizeDo something before every commandDo something when a shell function or a sourced file finishes executingPERFORMANCEDisable UnicodeOBSOLETE SYNTAXShebangCommand SubstitutionFunction DeclarationINTERNAL VARIABLESGet the location to the `bash` binaryGet the version of the current running `bash` processOpen the user's preferred text editorGet the name of the current functionGet the host-name of the systemGet the architecture of the Operating SystemGet the name of the Operating System / KernelGet the current working directoryGet the number of seconds the script has been runningGet a pseudorandom integerINFORMATION ABOUT THE TERMINALGet the terminal size in lines and columns (from a script)Get the terminal size in pixelsGet the current cursor positionCONVERSIONConvert a hex color to RGBConvert an RGB color to hexCODE GOLFShorter `for` loop syntaxShorter infinite loopsShorter function declarationShorter `if` syntaxSimpler `case` statement to set variableOTHERUse `read` as an alternative to the `sleep` commandCheck if a program is in the user's PATHGet the current date using `strftime`Get the username of the current userGenerate a UUID V4Progress barsGet the list of functions in a scriptBypass shell aliasesBypass shell functionsRun a command in the backgroundCapture the return value of a function without command substitutionAFTERWORD
README.md