Extract substring in Bash

You can use Parameter Expansion to do this. If a is constant, the following parameter expansion performs substring extraction: b=${a:12:5} where 12 is the offset (zero-based) and 5 is the length If the underscores around the digits are the only ones in the input, you can strip off the prefix and suffix (respectively) in two … Read more

What does set -e mean in a bash script?

From help set : -e Exit immediately if a command exits with a non-zero status. But it’s considered bad practice by some (bash FAQ and irc freenode #bash FAQ authors). It’s recommended to use: trap ‘do_something’ ERR to run do_something function when errors occur. See http://mywiki.wooledge.org/BashFAQ/105

Shell command to sum integers, one per line?

Bit of awk should do it? awk ‘{s+=$1} END {print s}’ mydatafile Note: some versions of awk have some odd behaviours if you are going to be adding anything exceeding 2^31 (2147483647). See comments for more background. One suggestion is to use printf rather than print: awk ‘{s+=$1} END {printf “%.0f”, s}’ mydatafile

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)