Scripting (was Re: Cron job for backup)

Lynn Newton lynn.newton at gmail.com
Tue Dec 11 13:45:54 MST 2007


> > I've heard this a couple times now, but never had anyone explain why the
> > $( ) format is preferred over the back quote in bash scripts. I have
> > begun to try remembering to use the $( ) format in my scripts now, but I
> > still find myself using back quotes quite often. So why is back quotes
> > not considered a good method of shelling out a command to the system?

That first appeared in Korn shell quite a number of years ago. It's
in KSH 88. As soon as I read about it (when KSH 88 was new), I adopted
the new way of doing it and never returned. As I recall, Korn called
the backtick notation obsolescent, tough it's obviously still there.

The man page says:

The standard output from a command enclosed in parenthesis preceded by
a dollar    sign ( $( ) ) or a pair of grave accents ( ` ` ) may be
used as part or all of a word; trailing new-lines are removed. In the
second (archaic) form, the string between the quotes is processed for
special quoting characters before the command is executed.

It seems the key word here is archaic ... and that's coming from the
author of ksh, upon which a large part of bash is based.

-- 
Lynn Newton


More information about the PLUG-discuss mailing list