![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Cronjob - Redirect mail output to file, LINES & COLUMNS | jharvey | Shell Programming and Scripting | 0 | 04-14-2008 03:19 PM |
| Redirect grep output into file !!!!! | hanu_oracle | Shell Programming and Scripting | 2 | 04-10-2008 09:02 AM |
| redirect output to log file | kalyanraj | Shell Programming and Scripting | 2 | 06-07-2007 12:40 AM |
| Redirect output to a file | jimmyc | UNIX for Dummies Questions & Answers | 11 | 01-31-2007 11:34 AM |
| redirect output to file? | slackware | Shell Programming and Scripting | 1 | 09-12-2003 02:57 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
redirect output to file
Hello,
I have a question about redirecting stdout and stderr. I have searched on Google and this forum and cant find the answer to my question. Normally when I write scripts, I specify the redirection on each individual command like so: echo hello > /some/file 2>&1 ls /home > /some/file 2>&1 What I want to do is have all the commands in my script output to a file without having to specify it on each individual command. I know one solution is to just specify the redirection in the crontab like so: * * * * * /some/script > /some/file 2>&1 I am just wondering if you can accomplish the same thing inside the script itself with some kind of global variable at the beginning of the script. Anyone know if this is possible and how? |
|
||||
|
Quote:
Right now I am doing this: (just example commands) Script: echo hello > /some/file ls /home > /some/file What I want to do is this: Script: echo hello ls /home I dont want to have to specify on each command where the output should go. I want to globally define it somewhere so that all commands output is redirected to where ever I define it. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|