[Nottingham] Backups: How do you do yours?

Mat Booth mbooth at fedoraproject.org
Wed Mar 16 15:56:48 UTC 2011


On 16 March 2011 14:34, Martin <martin at ml1.co.uk> wrote:
> Some very good comments all round.
>
>
>> An educational note about stream redirection, the command:
>>
>> command >>logfile.txt
>>
>> Will only append stdout to the file, anything printed on stderr will be lost.
>>
>> To capture both streams, the following command can be used:
>>
>> command 2>&1>>logfile.txt
>
> That doesn't work as intended...
>
> To redirect both stdout and stderr to a single file, you need to use:
>
> command >>logfile.txt 2>&1
>

Indeed so, well spotted. Sorry for my mis-information.


> That is: stdout is redirected to a file AND THEN stderr is redirected
> to the stdout-to-file.
>
> There's also a short form for doing that:
>
> command &>>logfile.txt
>
>


Yes, I quickly learned quickly not to use that short form though
because it's just not supported in many shell script implementations.
(Especially if you stray into brain-dead non-Linux environments like
Solaris or HP-UX... )


> The BASH syntax is quite an irregular mess! Almost as bad as a human language!!
>


Tell me about it. I'm one of the authors of ShellEd, the shell script
editor plug-in for Eclipse and although the formal grammar looks
straight-forward (this document details the spec:
http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html)
it's actually riddled with ambiguity and left-recursion. I couldn't
actually generate a full implementation of the syntax in ANTLR.  :-(

I'm no expert on grammar parser generators though, so it could just be
me not getting it, but BASH seems to made mostly of magic...


-- 
Mat Booth
http://fedoraproject.org/get-fedora



More information about the Nottingham mailing list