From: Rakesh Sharma on
On Mar 27, 12:07 am, pk <p...(a)pk.invalid> wrote:
> Rakesh Sharma wrote:
> > How do I make the STDERR go to STDOUT whilst nullifying the STDOUT
> > from
> > any command?
>
> > This doesn't work:
> >           command 3>&1 1>&2 2>&3 3> /dev/null
>
> This should do it:
>
> command 2>&1 1>/dev/null

Thanks for the concise answer. It so completely translates with the
problem statement!

-- Rakesh
From: Rakesh Sharma on
On Mar 27, 12:32 am, mop2 <inva...(a)mail.address> wrote:
> On Fri, 26 Mar 2010 16:02:10 -0300, Rakesh Sharma  
>
>
>
> <sharma...(a)hotmail.com> wrote:
> > How do I make the STDERR go to STDOUT whilst nullifying the STDOUT
> > from
> > any command?
>
> > This doesn't work:
> >           command 3>&1 1>&2 2>&3 3> /dev/null
>
> > I am going thru this rigamarole as I want to test for the  
> > existence of
> > a file in a portable manner.
> > test -e is not available on Solaris.
>
> > So I am doing this:
> >    status=`/bin/ls -d -- "filename" 3>&1 1>&2 2>&3`
> >    case $status in
> >     '' ) echo 'filename EXISTS';;
> >     *) >&2 echo "filename doesnt EXIST: $status";;
> >   esac
>
> > -- Rakesh
>
> Sorry, I dont know if this is portable.
> Here, with bash4 is ok:
>
> $ ls -ld /tmp /tmpppp 2>/dev/null >&2
> $

Would it not consign both (STDERR and STDOUT) to /dev/null? Actually,
that's not what I wanted.
STDERR should go to where STDOUT normally goes & the STDOUT should be
dumped in /dev/null.

-- Thanks,
Rakesh
From: Rakesh Sharma on
On Mar 27, 12:49 am, Jon LaBadie <jlaba...(a)aXcXm.org> wrote:
> Rakesh Sharma wrote:
> > How do I make the STDERR go to STDOUT whilst nullifying the STDOUT
> > from
> > any command?
>
> > This doesn't work:
> >           command 3>&1 1>&2 2>&3 3> /dev/null
>
> > I am going thru this rigamarole as I want to test for the existence of
> > a file in a portable manner.
> > test -e is not available on Solaris.
>
> Which Solaris?  Which shell?  Are you locked into /bin/sh?
>
> What about /bin/test for this one test.  My Solaris 9
> /bin/test has the -e option.

Solaris 5.8.
/bin/sh on Solaris
Not sure if I have Solaris 9 installed with us.

Thanks

-- Rakesh
From: Rakesh Sharma on
On Mar 27, 1:43 am, Seebs <usenet-nos...(a)seebs.net> wrote:
> On 2010-03-26, Rakesh Sharma <sharma...(a)hotmail.com> wrote:
>
> > How do I make the STDERR go to STDOUT whilst nullifying the STDOUT
> > from
> > any command?
>
> Typically, 2>&1 1>/dev/null
>
> Note that this doesn't work for pipes; "2>&1 | foo" ends up opening
> the pipe, then redirecting stderr to stdout.
>
> > I am going thru this rigamarole as I want to test for the existence of
> > a file in a portable manner.
>
> Hmm.
>
> > test -e is not available on Solaris.
>
> How about "test -f"?  If you're sure it's a plain file, that'll probably
> be a lot easier.
>
> -s
> --
> Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...(a)seebs.nethttp://www.seebs.net/log/<-- lawsuits, religion, and funny pictureshttp://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!


Thanks for the suggestion.
test -f will not work as file maybe anything: plain file/non-plain
file/directory/link/etc.

-- Rakesh
First  |  Prev  | 
Pages: 1 2
Prev: sed -f
Next: bash printing variable with newlines