Aug 10, 2017

More bash scripting

String split:
-------------------
#!/bin/bash
f="egan#mcclave"
substring="#"
##===========================================================================
# find the 'model_name'
index="$(echo $f | grep -b -o $substring | sed 's/:.*$//')" # redirecting the output of echo into a variable with "$(...)"
#echo $index
first=${f:0:$((index))} # taking the substring 0-index
echo "first : "$first
   
second=${f#*$substring} # find the occurrence of $substring in $f
echo "second : "$second

No comments:

Carlo Cipolla's Laws of Stupidity

    "By creating a graph of Cipolla's two factors, we obtain four groups of people. Helpless people contribute to society but are...