Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

C-shell :: redirecting stderr to /dev/null
What is the easiest way to redirect the standard error to a null file
in C-shell?  I am looking for something akin to what we do in ksh:

command 2> /dev/null

Thanks in advance,
Bhat


Report this thread to moderator Post Follow-up to this message
Old Post
Generic Usenet Account
04-07-05 09:00 PM


Re: C-shell :: redirecting stderr to /dev/null
"Generic Usenet Account" <usenet@sta.samsung.com> writes:

> What is the easiest way to redirect the standard error to a null file
> in C-shell?  I am looking for something akin to what we do in ksh:
>
> command 2> /dev/null
>

Can't be done. That's one of C shell limitations. Check "Csh Programming
Considered Harmful" for more of it at

http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/


Bye, Dragan


--
Dragan Cvetkovic,

To be or not to be is true. G. Boole      No it isn't.  L. E. J. Brouwer

!!! Sender/From address is bogus. Use reply-to one !!!

Report this thread to moderator Post Follow-up to this message
Old Post
Dragan Cvetkovic
04-07-05 09:00 PM


Re: C-shell :: redirecting stderr to /dev/null
"Generic Usenet Account" <usenet@sta.samsung.com> writes:
> What is the easiest way to redirect the standard error to a null file
> in C-shell?  I am looking for something akin to what we do in ksh:
>
> command 2> /dev/null

You can't do it directly, but there are workarounds.

If stdout happens to be /dev/tty, you can use:

( command > /dev/tty ) >& /dev/null

Or you can do this:

sh -c 'command 2> /dev/null'

--
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.

Report this thread to moderator Post Follow-up to this message
Old Post
Keith Thompson
04-08-05 01:57 AM


Re: C-shell :: redirecting stderr to /dev/null
Dragan Cvetkovic wrote:

> Can't be done. That's one of C shell limitations. Check "Csh
Programming
> Considered Harmful" for more of it at
>
> http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
>
>
> Bye, Dragan
>
>

There is one thing about C-shell that I really like and that is the
Variable Modifier feature.  I mean:

:h >>-->> Remove a trailing pathname component, leaving the head
[similar to dirname]

:t >>-->> Remove all leading pathname components, leaving the tail
[similar to basename]

And my personal favorites...

:r >>-->> Remove a trailing extension, leaving the root
:e >>-->> Remove all but the extension


Is there a good equivalent for :r or :e in non C-shell shells?

Thanks,
Bhat


Report this thread to moderator Post Follow-up to this message
Old Post
Generic Usenet Account
04-08-05 09:00 PM


Re: C-shell :: redirecting stderr to /dev/null
"Generic Usenet Account" <usenet@sta.samsung.com> writes:

> Dragan Cvetkovic wrote:
> 
>
> There is one thing about C-shell that I really like and that is the
> Variable Modifier feature.  I mean:

Bash can do those things in a more generic way.

> :h >>-->> Remove a trailing pathname component, leaving the head
> [similar to dirname]

${var%/*}

> :t >>-->> Remove all leading pathname components, leaving the tail
> [similar to basename]

${var##*/}

> And my personal favorites...
>
> :r >>-->> Remove a trailing extension, leaving the root

${var%.*}

> :e >>-->> Remove all but the extension

${var##*.}

> Is there a good equivalent for :r or :e in non C-shell shells?

See above.

--
Måns Rullgård
mru@inprovide.com

Report this thread to moderator Post Follow-up to this message
Old Post
Måns Rullgård
04-08-05 09:00 PM


Re: C-shell :: redirecting stderr to /dev/null
On Fri, 08 Apr 2005 07:56:32 -0700, Generic Usenet Account wrote:

> Dragan Cvetkovic wrote:
> There is one thing about C-shell that I really like and that is the
> Variable Modifier feature.  I mean:
>
> :h >>-->> Remove a trailing pathname component, leaving the head
> [similar to dirname]
>
> :t >>-->> Remove all leading pathname components, leaving the tail
> [similar to basename]
>
> And my personal favorites...
>
> :r >>-->> Remove a trailing extension, leaving the root
> :e >>-->> Remove all but the extension
>
>
> Is there a good equivalent for :r or :e in non C-shell shells?

:r	${var%.*}
:e	${var##*.}

are reasonable approximations.


Report this thread to moderator Post Follow-up to this message
Old Post
Icarus Sparry
04-08-05 09:00 PM


Re: C-shell :: redirecting stderr to /dev/null
%% Måns Rullgård <mru@inprovide.com> writes:

mr> Bash can do those things in a more generic way.

The %, %%, #, and ## modifiers are not bash-specific: they're defined in
the POSIX spec for sh.

--
----------------------------------------------------------------------------
---
Paul D. Smith <psmith@nortel.com>           HASMAT--HA Software Mthds & Tool
s
"Please remain calm...I may be mad, but I am a professional." --Mad Scientis
t
----------------------------------------------------------------------------
---
These are my opinions---Nortel Networks takes no responsibility for them.

Report this thread to moderator Post Follow-up to this message
Old Post
Paul D. Smith
04-09-05 08:58 AM


Re: C-shell :: redirecting stderr to /dev/null
"Paul D. Smith" <psmith@nortel.com> writes:

> %% Måns Rullgård <mru@inprovide.com> writes:
>
>   mr> Bash can do those things in a more generic way.
>
> The %, %%, #, and ## modifiers are not bash-specific: they're defined in
> the POSIX spec for sh.

Thanks for the clarification.  I wasn't sure it was POSIX, and wanted
to avoid being corrected in the other direction.

--
Måns Rullgård
mru@inprovide.com

Report this thread to moderator Post Follow-up to this message
Old Post
Måns Rullgård
04-09-05 08:58 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:56 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.