User Tools

Site Tools


bash_functions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
bash_functions [2014/09/29 01:25]
k2patel [Integer or Decimal]
bash_functions [2014/09/29 02:13]
k2patel [show array]
Line 324: Line 324:
  
 [[http://​www.linkedin.com/​groups/​Fridays-function-fpmul-Perform-floatingpoint-3716796.S.5921339472191987716?​view=&​item=5921339472191987716&​type=member&​gid=3716796&​trk=eml-b2_anet_digest-hero-1-hero-disc-disc-0&​midToken=AQG8JYIVdmXjvA&​fromEmail=fromEmail&​ut=3_RJ7vAOch56s1|From article]] [[http://​www.linkedin.com/​groups/​Fridays-function-fpmul-Perform-floatingpoint-3716796.S.5921339472191987716?​view=&​item=5921339472191987716&​type=member&​gid=3716796&​trk=eml-b2_anet_digest-hero-1-hero-disc-disc-0&​midToken=AQG8JYIVdmXjvA&​fromEmail=fromEmail&​ut=3_RJ7vAOch56s1|From article]]
 +
 +==== show array ====
 +<code bash>
 +ashow() #@ Display contents of array[s]
 +{ #@ USAGE: ashow ARRAYNAME ...
 +local _arg _num=0
 +for arg
 +do
 +:; ((_num++)) && echo
 +:; declare -n array=$arg
 +:; [[ -n ${array[*]} ]] && printf '​%s\n'​ "​${array[@]}"​
 +done
 +}
 +</​code>​
 +
 +[[https://​www.linkedin.com/​groups/​Fridays-function-ashow-Display-contents-3716796.S.5918816399794409474?​view=&​item=5918816399794409474&​type=member&​gid=3716796&​trk=eml-b2_anet_digest-hero-4-hero-disc-disc-0&​midToken=AQG8JYIVdmXjvA&​fromEmail=fromEmail&​ut=19mP4Lva0K56s1|From Article]]
 +
 +==== Reverse Word ====
 +<code bash>
 +revword() #@ Reverse the order of characters in STRING
 +{ #@ USAGE: revword STRING [VAR]
 +local _n _word=$1 _var=$2 _len _r _rw= _l
 +while read -n1 _l
 +do
 +_rw=$_l$_rw
 +done <<<​ "​$_word"​
 +[[ ${_var^^} =~ ^[A-Z_][A-Z0-9_]*$ ]] &&
 +printf -v "​$_var"​ %s "​$_rw"​ ||
 +printf '​%s\n'​ "​$_rw"​
 +}
 +</​code>​
 +
 +[[ https://​www.linkedin.com/​groups/​Fridays-function-revword-Reverse-order-3716796.S.5916260779903975428?​view=&​item=5916260779903975428&​type=member&​gid=3716796&​trk=eml-b2_anet_digest-hero-1-hero-disc-disc-0&​midToken=AQG8JYIVdmXjvA&​fromEmail=fromEmail&​ut=13sqjyjg1356s1 | From Article ]]
bash_functions.txt ยท Last modified: 2020/08/10 02:35 (external edit)