while sizes=`sizes $pgid`
do
set -- $sizes
sample=$((${@/#/+}))
let peak="sample > peak ? sample : peak"
sleep 0.1
done
i am confused about the below statement:
sample=$((${@/#/+}))
could anybody explain this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The ‘
${@/#/+}‘ part is a regular expression expansion:So, it looks like it replaces the empty string at the start of each value in the argument list ‘
$@‘ with a ‘+‘. It’s key merit is that it prefixes each argument in one fell swoop; otherwise, it is similar to"+$var".The ‘
$(( ... ))part is an arithmetic expression. It performs arithmetic on the expression between the parentheses. So, in context, it adds up the values in the argument list, assuming they are all numeric. Given the expansion, it might yield:and hence ‘
28 = 28‘.