search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

GitHub標星2.4W!五分鐘帶你搞定LINUX Bash腳本(SHELL)使用技巧 – jashliao部落格

GitHub標星2.4W!五分鐘帶你搞定LINUX Bash腳本(SHELL)使用技巧


資料來源: https://github.com/dylanaraps/pure-bash-bible


FOREWORD

STRINGS
    Trim leading and trailing white-space from string
    Trim all white-space from string and truncate spaces
    Use regex on a string
    Split a string on a delimiter
    Change a string to lowercase
    Change a string to uppercase
    Reverse a string case
    Trim quotes from a string
    Strip all instances of pattern from string
    Strip first occurrence of pattern from string
    Strip pattern from start of string
    Strip pattern from end of string
    Percent-encode a string
    Decode a percent-encoded string
    Check if string contains a sub-string
    Check if string starts with sub-string
    Check if string ends with sub-string
ARRAYS
    Reverse an array
    Remove duplicate array elements
    Random array element
    Cycle through an array
    Toggle between two values
LOOPS
    Loop over a range of numbers
    Loop over a variable range of numbers
    Loop over an array
    Loop over an array with an index
    Loop over the contents of a file
    Loop over files and directories
FILE HANDLING
    Read a file to a string
    Read a file to an array (by line)
    Get the first N lines of a file
    Get the last N lines of a file
    Get the number of lines in a file
    Count files or directories in directory
    Create an empty file
    Extract lines between two markers
FILE PATHS
    Get the directory name of a file path
    Get the base-name of a file path
VARIABLES
    Assign and access a variable using a variable
    Name a variable based on another variable
ESCAPE SEQUENCES
    Text Colors
    Text Attributes
    Cursor Movement
    Erasing Text
PARAMETER EXPANSION
    Indirection
    Replacement
    Length
    Expansion
    Case Modification
    Default Value
    BRACE EXPANSION
    Ranges
    String Lists
CONDITIONAL EXPRESSIONS
    File Conditionals
    File Comparisons
    Variable Conditionals
    Variable Comparisons
ARITHMETIC OPERATORS
    Assignment
    Arithmetic
    Bitwise
    Logical
    Miscellaneous
ARITHMETIC
    Simpler syntax to set variables
    Ternary Tests
TRAPS
    Do something on script exit
    Ignore terminal interrupt (CTRL+C, SIGINT)
    React to window resize
    Do something before every command
    Do something when a shell function or a sourced file finishes executing
PERFORMANCE
    Disable Unicode
    OBSOLETE SYNTAX
    Shebang
    Command Substitution
    Function Declaration
INTERNAL VARIABLES
    Get the location to the bash binary
    Get the version of the current running bash process
    Open the user’s preferred text editor
    Get the name of the current function
    Get the host-name of the system
    Get the architecture of the Operating System
    Get the name of the Operating System / Kernel
    Get the current working directory
    Get the number of seconds the script has been running
    Get a pseudorandom integer
INFORMATION ABOUT THE TERMINAL
    Get the terminal size in lines and columns (from a script)
    Get the terminal size in pixels
    Get the current cursor position
CONVERSION
    Convert a hex color to RGB
    Convert an RGB color to hex
CODE GOLF
    Shorter for loop syntax
    Shorter infinite loops
    Shorter function declaration
    Shorter if syntax
    Simpler case statement to set variable
OTHER
    Use read as an alternative to the sleep command
    Check if a program is in the user’s PATH
    Get the current date using strftime
    Get the username of the current user
    Generate a UUID V4
    Progress bars
    Get the list of functions in a script
    Bypass shell aliases
    Bypass shell functions
    Run a command in the background
AFTERWORD

前言
STRINGS
    修剪字符串的前導和尾隨空格
    修剪字符串中的所有空白並截斷空格
    在字符串上使用正則表達式
    在定界符上分割字符串
    將字符串更改為小寫
    將字符串更改為大寫
    反轉字符串大小寫
    修剪字符串中的引號
    從字符串中剝離模式的所有實例
    從字符串中刪除模式的首次出現
    從字符串的開頭剝離圖案
    字符串末尾的帶狀圖案
    對字符串進行百分比編碼
    解碼百分比編碼的字符串
    檢查字符串是否包含子字符串
    檢查字符串是否以子字符串開頭
    檢查字符串是否以子字符串結尾
陣列
    反轉數組
    刪除重複的數組元素
    隨機數組元素
    遍歷數組
    在兩個值之間切換
圈數
    循環顯示一系列數字
    循環遍歷可變範圍的數字
    遍歷數組
    用索引循環遍歷數組
    循環遍歷文件的內容
    循環遍歷文件和目錄
文件處理
    將文件讀取為字符串
    將文件讀取到數組(按行)
    獲取文件的前N行
    獲取文件的最後N行
    獲取文件中的行數
    計算目錄中的文件或目錄
    創建一個空文件
    提取兩個標記之間的線
文件路徑
    獲取文件路徑的目錄名稱
    獲取文件路徑的基本名稱
變數
    使用變量分配和訪問變量
    根據另一個變量命名一個變量
逃逸序列
    文字顏色
    文字屬性
    光標移動
    刪除文字
參數擴展
    間接的
    替代
    長度
    擴張
    案例修改
    默認值
擴展支架
    範圍
    字串清單
條件表達
    文件條件
    文件比較
    可變條件
    變量比較
算術運算符
    分配
    算術
    按位
    邏輯上
    雜
算術
    設置變量的語法更簡單
    三元測試
陷阱
    在腳本退出時執行一些操作
    忽略終端中斷(CTRL + C,SIGINT)
    對窗口調整大小做出反應
    在執行每個命令之前先做點事
    當Shell函數或源文件執行完成時執行一些操作
性能
    禁用Unicode
過時的語法
    舍邦
    命令替換
    功能聲明
內部變量
    獲取bash二進製文件的位置
    獲取當前運行bash進程的版本
    打開用戶的首選文本編輯器
    獲取當前函數的名稱
    獲取系統的主機名
    獲取操作系統的體系結構
    獲取操作系統/內核的名稱
    獲取當前工作目錄
    獲取腳本已運行的秒數
    獲取一個偽隨機整數
有關端子的信息
    獲取行和列的終端大小(通過腳本)
    獲取終端尺寸(以像素為單位)
    獲取當前光標位置
轉換
    將十六進制顏色轉換為RGB
    將RGB顏色轉換為十六進制
高爾夫代碼
    較短的for循環語法
    較短的無限循環
    較短的函數聲明
    if語法較短
    case設置變量的簡單語句
其他
    使用read作為替代的sleep命令
    檢查程序是否在用戶的PATH中
    使用獲取當前日期 strftime
    獲取當前用戶的用戶名
    生成UUID V4
    進度條
    獲取腳本中的功能列表
    繞過外殼別名
    繞過外殼功能
    在後台運行命令
詞尾



熱門推薦

本文由 jashliaoeuwordpress 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦