dateDiff(){ echo enter first time stamp TIME1=`date +%H:%M:%S` echo enter second time stamp TIME2=23:59:59 H1=`date +%H` echo "Hour="$H1 M1=`date +%M` echo "Mintue="$M1 S1=`date +%S` H2=23 M2=59 S2=59 H1=${H1#0} M1=${M1#0} H2=${H2#0} M2=${M2#0} ((MAM1=H1+(M1/60)+(S1/3600))) ((MAM2=H2+(M2/60)+(S2/3600))) ((diff=MAM2-MAM1)) echo diff = $diff return $diff }
$ a='00abc' $ echo ${a#0} 0abc
The following four varieties of parameter expansion provide for substring processing. In each case, pattern matching notation (see patmat), rather than regular expression nota- tion, will be used to evaluate the patterns. If parameter is * or @, then all the positional parameters, starting with $1, are substituted (separated by a field separator charac- ter). Enclosing the full parameter expansion string in double-quotes will not cause the following four varieties of pattern characters to be quoted, whereas quoting characters within the braces will have this effect. ${parameter%word} Remove Smallest Suffix Pattern. The word will be expanded to produce a pattern. The parameter expansion then will result in parameter, with the smallest por- tion of the suffix matched by the pattern deleted. ${parameter%%word} Remove Largest Suffix Pattern. The word will be expanded to produce a pattern. The parameter expansion then will result in parameter, with the largest por- tion of the suffix matched by the pattern deleted. ${parameter#word} Remove Smallest Prefix Pattern. The word will be expanded to produce a pattern. The parameter expansion then will result in parameter, with the smallest por- tion of the prefix matched by the pattern deleted. ${parameter##word} Remove Largest Prefix Pattern. The word will be expanded to produce a pattern. The parameter expansion then will result in parameter, with the largest por- tion of the prefix matched by the pattern deleted.