LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (http://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   how to set redirect for all commands (http://www.linuxquestions.org/questions/linux-from-scratch-13/how-to-set-redirect-for-all-commands-671005/)

hillpigLQ 09-19-2008 04:42 AM

how to set redirect for all commands
 
i know the redirect command can be wrote such as:$ ls > filelist.txt,are there any commands used to set the global redirect,so i don't need add each command >. thks

theNbomr 09-19-2008 12:27 PM

You could launch a sub-shell with its standard In/Out/Err file descriptors redirected. Any processes launched by that sub-shell will inherit the redirected file descriptors.
File 'bashStdin.txt':
Code:

echo $SHLVL
date
exit

Code:

echo $SHLVL
bash < bashStdin.txt

Output:
Code:

3
4
Fri Sep 19 10:23:03 PDT 2008

The same can be applied to standard out & standard error.
--- rod.


All times are GMT -5. The time now is 11:22 PM.