Home > Archive > Unix Programming > April 2005 > C-shell :: redirecting stderr to /dev/null
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
C-shell :: redirecting stderr to /dev/null
|
|
| Generic Usenet Account 2005-04-07, 4:00 pm |
| 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
| |
| Dragan Cvetkovic 2005-04-07, 4:00 pm |
| "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 !!!
| |
| Keith Thompson 2005-04-07, 8:57 pm |
| "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.
| |
| Generic Usenet Account 2005-04-08, 4:00 pm |
| 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
| |
| Måns Rullgård 2005-04-08, 4:00 pm |
| "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
| |
| Icarus Sparry 2005-04-08, 4:00 pm |
| 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.
| |
| Paul D. Smith 2005-04-09, 3:58 am |
| %% 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 & Tools
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
These are my opinions---Nortel Networks takes no responsibility for them.
| |
| Måns Rullgård 2005-04-09, 3:58 am |
| "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
|
|
|
|
|