LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to set redirect for all commands (http://www.linuxquestions.org/questions/linux-newbie-8/how-to-set-redirect-for-all-commands-671010/)

hillpigLQ 09-19-2008 05:51 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

i92guboj 09-19-2008 06:51 AM

I guess you want this:

Code:

#!/bin/bash

exec > file.log 2>&1

# The rest of your script

You can as well redirect the output for concrete code blocks, like this:

Code:

#!/bin/bash

{
  # my code block
} > file.log 2>&1

# The rest of your script



All times are GMT -5. The time now is 02:24 PM.