Shell Scripting Quotes and Brackets - miraj/tools GitHub Wiki
In general double quote is for strings
grep "sub testCase_" testcase.pm
Variable substitution happens within double quotes
tc="12345" grep "sub testCase_$tc" testcase.pm is equivelent to grep "sub testCase_12345" testcase.pm
Special characters are not special anymore in double quotes
They are considered as normal characters
ls * ls args.p[lm] ls "*" ls "args.p[lm]"
double quoted string can contain single quote
No variable substitution
No special characters
num="10" echo '$num' echo "$num"
grep 'sub ' code.pl | wc -l if you need the count in a variable lines=`grep 'sub ' code.pl | wc -l`
grep PASS log.txt echo $?
sleep 5; echo 5 minutes passed
gcc -o sendmessage sendmessage.c ; ./sendmessage -t -a 1; cat /tmp/message
gcc -o sendmessage sendmessage.c && ./sendmessage -t -a 1 && cat /tmp/message
echo $result | grep PASS || exit 1 # code to handle success
Make sure there is space after [[and]]
if [ [ "$status" == "PASSED" ] ] then release="yes" fi
[ [ $num -lt 3 ] ] && exit 1;
(sleep 5; echo Done) (grep PASS log.txt; grep FAIL log.txt) > results.txt
grep FAIL result.txt && { echo "Test case $tc failed"; exit 1; }
echo $((140 / 5 / 5))
lines=`wc -l file.txt` files=`ls * | wc -l` total=$((lines*files))