[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fwd: Is this a design oversight? BASH redirection failure
From: |
John McKown |
Subject: |
Fwd: Is this a design oversight? BASH redirection failure |
Date: |
Tue, 24 Feb 2015 12:48:00 -0600 |
I run with "set -o noclobber". I know to use >| to redirect stdout and
overwrite an existing file. But I often want to redirect both stdout
and stderr to the same file. Which I do with the &> operator. But I
cannot _easily_ redirect both and overwrite at the same time. I was
expecting &>| to work, but it doesn't.
transcript:
[tsh009@it-johnmckown-linux junk]$ set -o noclobber
[tsh009@it-johnmckown-linux junk]$ touch x
[tsh009@it-johnmckown-linux junk]$ echo >x
bash: x: cannot overwrite existing file
[tsh009@it-johnmckown-linux junk]$ echo x >|x
[tsh009@it-johnmckown-linux junk]$ echo x &>x
bash: x: cannot overwrite existing file
[tsh009@it-johnmckown-linux junk]$ echo x &>|x
bash: syntax error near unexpected token `|'
this works
[tsh009@it-johnmckown-linux junk]$ echo x >|x 2>&1
[tsh009@it-johnmckown-linux junk]$
[tsh009@it-johnmckown-linux junk]$ uname -a;bash --version
Linux it-johnmckown-linux 3.18.3-201.fc21.x86_64 #1 SMP Mon Jan 19
15:59:31 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
GNU bash, version 4.3.33(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Yes, I'm a lazy typist. :-)
--
He's about as useful as a wax frying pan.
10 to the 12th power microphones = 1 Megaphone
Maranatha! <><
John McKown