What is the difference between filename=${1:-/etc/hosts}
and filename=/etc/hosts
?
For example:
filename=/etc/hosts
if [ -r "$filename" ] && [ -s "$filename" ]; then
md5sum $filename
else
echo "$filename cannot be processed"
fi
and
filename=${1:-/etc/hosts}
if [ -r "$filename" ] && [ -s "$filename" ]; then
md5sum $filename
else
echo "$filename cannot be processed"
fi
$1
to null,/etc/hosts
is assigned tofilename
. – cuonglm Jun 29 '14 at 12:05./yourscript "" 2 3
,filename
is set to/etc/hosts
even if you had pass$1
to script. – cuonglm Jun 29 '14 at 12:23