|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
It is a newbie general question. I want to redirect the result of bdf (or df -k) in a file. I tried this. [%] echo $SHELL ksh [%] bdf > toto ; bdf | tee toto ; bdf 2>toto My Pb is that size of toto is always 0 Why ? How to redirect bdf output into toto file ? Thanks |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On 2006-11-07, YAB wrote:
> Hi, > It is a newbie general question. I want to redirect the result of bdf (or > df -k) in a > file. > > I tried this. > [%] echo $SHELL > ksh > [%] bdf > toto ; bdf | tee toto ; bdf 2>toto > > My Pb is that size of toto is always 0 > Why ? How to redirect bdf output into toto file ? All of those should work. What is the output of bdf without any redirection? Post the output of: bdf | tee toto ls -l toto -- Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Wed, 8 Nov 2006 00:50:41 +0100, YAB
<yhab.abiad@orange.fr> wrote: > Hi, > It is a newbie general question. I want to redirect the result of bdf (or > df -k) in a > file. > > I tried this. > [%] echo $SHELL > ksh > [%] bdf > toto ; bdf | tee toto ; bdf 2>toto > Each command erases the previous content of toto. Try using >> instead of >, and "tee -a". Or you could use bdf > toto 2>&1 -- meterologist, n.: One who doubts the established fact that it is bound to rain if you forget your umbrella. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Of course, I've executed commands seperatly and after each command I've run
ls -l bdf => gives a correct standard output bdf > toto => then ls -l toto prints 0 length for toto and so on for other commands (bdf | tee toto). All your answers confirm that there is no syntax error with my command. I'll try with bdf >> toto and with bdf | tee -a toto I'll check also if there is a quota limit with my account. Many thanks for your answers. "Bill Marcum" <bmarcum@iglou.com> a écrit dans le message de news:3h5824-989.ln1@don.localnet... > On Wed, 8 Nov 2006 00:50:41 +0100, YAB > <yhab.abiad@orange.fr> wrote: > > Hi, > > It is a newbie general question. I want to redirect the result of bdf (or > > df -k) in a > > file. > > > > I tried this. > > [%] echo $SHELL > > ksh > > [%] bdf > toto ; bdf | tee toto ; bdf 2>toto > > > Each command erases the previous content of toto. Try using >> instead > of >, and "tee -a". Or you could use > bdf > toto 2>&1 > > > -- > meterologist, n.: > One who doubts the established fact that it is > bound to rain if you forget your umbrella. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
YAB wrote:
> Hi, > It is a newbie general question. I want to redirect the result of bdf (or > df -k) in a > file. > > I tried this. > [%] echo $SHELL > ksh > [%] bdf > toto ; bdf | tee toto ; bdf 2>toto ^^^^^^^^^^ this last command is the only one that matters it must be that the bdf command produces no output on stderr > My Pb is that size of toto is always 0 > Why ? the shell is redirecting stderr output from bdf to file toto we know that toto is overwritten before bdf is executed (the techincal term is truncated) which is just a natural consequence of how shell redirection works but since bdf produces no output on stderr, nothing is ever written to toto, thus toto remains at 0 bytes > How to redirect bdf output into toto file ? bdf > toto # overwrite contents of toto bdf >> toto # append to contents to toto -- Posted via a free Usenet account from http://www.teranews.com |
|
![]() |
| Outils de la discussion | |
|
|