Linux.com

Home Learn Linux Linux Tutorials More Bash Redirections

More Bash Redirections

Everybody's seen redirection in bash commands, that's pretty common, but bash also allows you to define redirections when you define functions. This causes the redirections to be evaluated/executed whenever the function is called. This feature doesn't really give you any new features, just another way to express existing features.

The syntax for this is simple, you simply append the redirections onto the end of the function defintion:

function testy()
{
...
} < testy.in > testy.out 2> testy.err

Now whenever the function testy is called its input will come from testy.in, its output will go to testy.out and any errors will go to testy.err.

Article Source Linux Journal
October 6, 2009, 10:22 am
Read More

 

Comments

Subscribe to Comments Feed

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board