[wplug] Line-by-line input from stdin, from a bash script?
Vance Kochenderfer
vkochend at nyx.net
Sat Oct 19 00:28:55 EDT 2013
Pat Barron <pat at lectroid.com> wrote:
> On 10/15/2013 12:51 PM, Eric Cooper wrote:
> > line=$(head -1)
>
> I didn't even know that's something you can do... ;-)
Just as a general shell scripting note, $(command) does the same
thing as `command`. The backquotes are the traditional syntax,
while the other is newer but should be supported most everywhere
(it's been in the POSIX standard since 1997, if not earlier).
The $( ) form is a bit more robust. I try to use it exclusively
in any new scripts. There are special rules about how backslashes
and quotes are treated within the backquotes form.
<http://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html#tag_23_02_06_03>
<http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_03>
Somewhat related, there is a bashism, $(< file), which is the same
as $(cat file). It is slightly faster since it doesn't fire up an
instance of cat, but it is NOT part of POSIX.
Vance Kochenderfer | "Get me out of these ropes and into a
vkochend at nyx.net | good belt of Scotch" -Nick Danger
More information about the wplug
mailing list