Linux weirdness (Commands that don't behave as I would have expected)

Tony Hammitt thammitt at kc.rr.com
Tue Sep 18 02:33:55 CDT 2001


It all depends on which shell you are using.  In bash or zsh, a '>' sends
the stdout to a file but you have to use:

find / -name services >/dev/null 2>&1

to get the stderr stream combined with the stdout stream and then sent to
/dev/null.  (note that the streams aren't necessarily combined cleanly
when you do this, you will likely get some memory pages of output from
stdout and then some from stderr if there is a lot of output from both)
Did you get any output like '/etc/services' or just a bunch of:

find: /dev/dri: Permission denied
find: /etc/cups/certs: Permission denied

'wc adjtime' is a lot easier to understand than '<adjtime wc', why do you
need to use the second construct?  It could be that your shell is just
disregarding the unexpected stream of data instead of just displaying it??
In tcsh, I get 'Invalid null command.' when I try the '<adjtime', I think
that it is trying to say that I haven't specified what to do with the data.
Why should it run it through 'cat'?  Why not 'trilobite-inventory-service'
just to pick a random executable??

Using 'tee' sends its stdin to stdout and the named file, so it's not too
surprising that you got two copies of the data.

I think that everything is working as it's supposed to, perhaps another
system did things differently.  I could check the ksh manpage tomorrow at
work, it does some things in its own way.

HTH,

	Tony

Bill Clark wrote:
> 
> Perhaps my my memory is clouded, as over the last ten years I have worked on
> a lot of different *NIX flavors.  I made a small list of things that don't
> work and I think should work.  Maybe somebody here has some insite as to why
> the following doesn't work anymore at least under Suse 7.2.  I will check
> other *NIX versions at work to see if it's just Suse but I don't think so.
> 
> find / -name services >/dev/null
> should send STDOUT to /dev/null but it doesn't
> 
> grep tcp services >/dev/null works
> grep tcp * >/dev/null doesn't work (could the * metacharater be fouling this
> up some how?)
> 
> <adjtime is supposed get STDIN from a file but it doen't work. It should be
> an alternative to typing cat filename.  I get the prompt returned with no
> data.
> <adjtime wc produces an accurate word count but no display of file contents
> <adjtime tee /dev/pts/0 <-----this is my terminal window.  It produces
> contents of the file twice on my screen, yet <adjtime produces nothing.
> 
> Bill
> bill at billclark.net
> 




More information about the Kclug mailing list