Bash Shell 如何接收並切割字串

Linux 於 Bash Shell 如何將檔案內的內容切割到每個變數,或者如何撈外部 API 的內容,並 assign 到每個變數去?

閱讀全文〈Bash Shell 如何接收並切割字串〉

gorun:使用 Go 當 Script language

Golang 除了 Compile (build) 外,平常可以使用 go run 直接執行。

gorun 的作者想要在 go 的程式第一行加上類似 #!/usr/bin/go 就可以執行 .go 的作法

  • 詳見:GitHub - erning/gorun: gorun is a tool enabling one to put a "bang line" in the source code of a Go program to run it, or to run such a source code file explicitly. It was created in an attempt to make experimenting with Go more appealing to people used to Python and similar languages which operate most visibly with source code.

閱讀全文〈gorun:使用 Go 當 Script language〉

Linux 使用 find、read 對目錄內的指定檔案做處理

Linux 於 Bash shell (CLI) 要把檔案列出來,再來要抓出每個檔名,再分別處理,script 要怎麼寫呢?

閱讀全文〈Linux 使用 find、read 對目錄內的指定檔案做處理〉

Linux 快速查看網路、硬碟、負載、記憶體使用情況的 Shell Script

Linux 做系統監控,最基本的就是網路、CPU、硬碟、Load Average (uptime)、RAM、SWAP 等等,若系統有問題時,這些也是首先查看的點。

此程式就是可以快速將這些資訊整理起來,一次呈現,所以若有問題時,登入系統直接執行,可以省掉不少時間。

閱讀全文〈Linux 快速查看網路、硬碟、負載、記憶體使用情況的 Shell Script〉

Bash script 取得自己的檔案名稱

Bash 的 Shell script 要抓自己的檔案名稱,只要用 $0 就可以抓到,不過 Shell script 若被呼叫時,用 $0 抓到的名稱是如何呢?

另外,Bash 有哪些預設的變數可以使用呢?

閱讀全文〈Bash script 取得自己的檔案名稱〉