Bash Quirkiness

David Cary Hart Fedora at TQMcube.com
Mon Jul 26 15:07:23 UTC 2004


Bash is astonishingly fussy about spacing and punctuation.

Here's a (admittedly very inelegant) snippet of code to automatically
generate exploit abuse complaints from a cron job.

while read evil freq ; do
	if [ "$freq" -gt 250 ] ; then
		a=`host $evil`
		c=`expr "$a" : '.*\(\..*\.net\)'`
		evilisp=${c/\./abuse\@}
			if [ $evilisp > "0" ] ; then
. . . . .

Note the use of both ' and ` in the line with the "expr." I find that
they are not interchangeable. Assigning a variable to an 'expr' will not
work without the "`". In fact, I cut and pasted it from some web docs.
I'm not even really sure what character it is. 

Can someone point me to documentation that fully explains this
punctuation issue?  Yes, I know that there are alternatives like awk and
perl but I would like to understand the bash issue.






More information about the fedora-list mailing list