LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-19-2008, 04:51 AM   #1
hillpigLQ
LQ Newbie
 
Registered: Jul 2008
Posts: 5

Rep: Reputation: 0
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
 
Old 09-19-2008, 05:51 AM   #2
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,036

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to set redirect command can be wrote such as:$ ls > filelist.txt,are there hillpigLQ Linux From Scratch 2 09-19-2008 09:55 PM
how to set redirect for all commands hillpigLQ Linux From Scratch 1 09-19-2008 12:27 PM
Etch Grub commands and set up Linux31 Debian 2 12-24-2006 05:36 AM
Set the path for shell commands??? acidblue Fedora 2 12-23-2005 11:23 PM
Setenv / set commands asaba Linux - Software 6 03-02-2005 04:35 AM


All times are GMT -5. The time now is 12:43 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration