Why does the regex in bash works only if it is a variable and not directly? [duplicate]
Why does the regex in bash works only if it is a variable and not directly? [duplicate]
Why does the regex in bash works only if it is a variable and not directly? [duplicate]
I think the simplest solution is just to use bash builtins: #!/bin/bash hostlist=${1//:/ } # this will replace all : with a space … Read more
How to check if variable contains valid UTF-8 string without any control characters?
Using perl: $ echo 100000011100 | perl -nle ‘ for ($i = 0; $i < length()/2; $i++) { print substr($_,$i,1), substr($_,$i+6,1); } ‘ … Read more
As addition to the John1024 answer (can’t commenting). Tried this method and found shortcut: Type full file name, which needed cut, using autocompletion … Read more
You can also do this (and many other things) using figlet with the binary font. $ echo foo | figlet -f binary 01100110 … Read more
The command [ -z $OUT ] is exactly equivalent to test -z $OUT which, if $OUT is empty, is the same as test … Read more
I can’t reproduce the problem with associative arrays: #! /bin/bash declare -A dailyData today=2021-02-08 todayData=whatever dailyData[“$today”]=”$todayData” But, if I use normal arrays, i.e. … Read more
The :global command that you reference in your question actually doesn’t just take literal strings, it handles any regular expression. So, you just … Read more
There are several options (bash first, POSIX is below). The code inside each function could be easily used outside. #!/bin/bash nl=$’\n’ aregex (){ … Read more