Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this message"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 !!!
Post Follow-up to this message"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.
Post Follow-up to this messageDragan 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
Post Follow-up to this message"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
Post Follow-up to this messageOn 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.
Post Follow-up to this message%% 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.
Post Follow-up to this message"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
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.