Unix Shell - redirection (was: find)

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > April 2005 > redirection (was: find)





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 redirection (was: find)
Sven Mascheck

2005-04-27, 2:48 am

Keith Thompson wrote:
> Janis Papanagnou writes:
>
>
> [...] all shells I know of (including csh and bash) allow it to
> be put just about anywhere.



There are a few exceptions to this general rule:

- redirections may only precede simple commands in POSIX.2
and traditional behaviour is varying

"< file { cmd; }" is illegal
(in contrast to "{ cmd; } < file")
because { } are not special like ( )

"< file ( cmd; )" is often legal
bash doesn't allow it (see its FAQ)

- "f() { cmd; } > file" gives unexpected and varying results
(this is more about orthogonality than usefulness)

- in Bourne shells, especially "2>&1 cmd >file"
interestingly also redirects stderr (except SunOS 5.6+)

historic:

- Bourne shells before SVR2 didn't allow to redirect a fd again
"eval 'cmd > file1' > file2"

Sven
--
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com