bash_functions
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| bash_functions [2014/09/29 02:13] – [show array] k2patel | bash_functions [2020/08/10 02:35] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 357: | Line 357: | ||
| [[ https:// | [[ https:// | ||
| + | |||
| + | ==== Trim Spaces ==== | ||
| + | <code bash> | ||
| + | trim() #@ Trim spaces (or char in $2) from both ends of $1 | ||
| + | { #@ USAGE: trim STRING [CHAR [VAR]] | ||
| + | local _trim_string _trim=$1 _char=${2:- } _var=$3 | ||
| + | _trim_string=${_trim## | ||
| + | _trim=${_trim%" | ||
| + | _trim_string=${_trim%%[!$_char]*} | ||
| + | _trim=${_trim#" | ||
| + | is_var " | ||
| + | printf -v " | ||
| + | printf ' | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | [[ https:// | ||
bash_functions.1411956790.txt.gz · Last modified: 2020/08/10 02:28 (external edit)