Sponsored Content
Top Forums Shell Programming and Scripting Redirect Output and Error in 2 different files Post 302419005 by itkamaraj on Thursday 6th of May 2010 03:14:54 AM
Old 05-06-2010
This is the basic command to redirect the output and error to two different files

Code:
prog >>& file	prog >> file 2>&1

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Redirect output to multiple files.

Hi, I am new to shell scripting and have a question. I would like to redirect the output of a command to multiple files, each file holding the exact same copy. From what I read from the bash manpage and from some searching it seems it cannot be done within the shell except setting up a loop. Is... (3 Replies)
Discussion started by: cbkihong
3 Replies

2. Shell Programming and Scripting

Ping: redirect output and error

Hi, I use this function (now modified with elif) for check if a pc is up: check_pc() { $PING $PC 1 2> /dev/null if ; then check_dir #Other function echo "Begin backup operation for $PC" echo "$SMBTAR -s $PC -u $USER -p $PASS -x $SHARE$EXCL -t - | gzip -c >... (3 Replies)
Discussion started by: mbarberis
3 Replies

3. Shell Programming and Scripting

How redirect output(error and normal) to 2 different files

Hello, I have a java program which i am calling in shell script. I wanted to redirect output to 2 differetn files. Output should have both 1 & 2 (normal and error) in both file. pls help (2 Replies)
Discussion started by: balareddy
2 Replies

4. Shell Programming and Scripting

Dynamically redirect output to duplicate files ???

Hi There are many posts in this forum regarding reditecting output, but mine is a different problem, please have a look. My shell script is redirecting output to a log file dynamically. That is it is using - exec > log1.txt 2>&1 Hence all the traces are appearing in the log1.txt. I want... (3 Replies)
Discussion started by: nsinha
3 Replies

5. Shell Programming and Scripting

redirect only the standard error output to mail

I'm writing a script using file descriptor 2 (std error) to send an email only if the command fails or errors out but the script always emails me irrepective of whether it fails or not. It will not email the /tmp/check.error file output if doesn't error out just the mail with the subject "Cannot... (3 Replies)
Discussion started by: barkath
3 Replies

6. Shell Programming and Scripting

Ambiguous output redirect error

Hi everyone, While I was trying to do DATE=`date +"%Y%m%d_%H%M%S"` STARTLOG=$TUXSTDDIR/start_$DATE.log tmboot -y > $STARTLOG 2>&1 I got an error i.e. Ambiguous output redirect error. Here the first part is to boot the account so there is nothing wrong with that.... (6 Replies)
Discussion started by: pareshan
6 Replies

7. Shell Programming and Scripting

How to redirect the output to multiple files without putting on console

How to redirect the output to multiple files without putting on console I tried tee but it writes to STDOUT , which I do not want. Test.sh ------------------ #!/bin/ksh echo "Hello " tee -a file1 file2 ---------------------------- $>./Test.sh $> Expected output: -------------------... (2 Replies)
Discussion started by: prashant43
2 Replies

8. Linux

Ambiguous redirect error and syntax error when using on multiple files

Hi, I need help on following linux bash script. When I linux commands for loop or while loop on individual file it runs great. but now I want the script to run on N number of files so it gives me ambiguous redirect error on line 12 and syntax error on line 22 : (pls help ); #!/bin/bash #... (16 Replies)
Discussion started by: Madhusudan Das
16 Replies

9. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

10. Shell Programming and Scripting

Redirect script output to a file and mail the output

Hi Guys, I want to redirect the output of 3 scripts to a file and then mail the output of those three scripts. I used below but it is not working: OFILE=/home/home1/report1 echo "report1 details" > $OFILE =/home/home1/1.sh > $OFILE echo... (7 Replies)
Discussion started by: Vivekit82
7 Replies
strmerge(1)						      General Commands Manual						       strmerge(1)

NAME
strmerge - batch string replacement SYNOPSIS
strmerge [-m prefix] [-p patternfile] [-s string] source-program... OPTIONS
Add prefix to message numbers in the output source program and source message catalog. You can use this prefix as a mnemonic. You must process source message catalogs that contain number prefixes using the mkcatdefs command. Message numbers will be in the form: <prefix><msg_num> Set numbers will be in the form: S_<prefix><set_num> If you process your input source program with the mkcatdefs command, the resulting source program and source message catalog might not be portable. For more information, see the Writing Software for the International Market. Use patternfile to match strings in the input source program. By default, the command searches for the pattern file in the current directory, your home directory and finally /usr/lib/nls. If you omit the -p option, the strmerge command uses a default patterns file that is stored in /usr/lib/nls/patterns. Write string at the top of the source message catalog. If you omit the -s option, strmerge uses the string specified in the $CATHEAD section of the patterns file. DESCRIPTION
The strmerge command reads the strings specified in the message file produced by strextract and replaces those strings with calls to the message file in the source program to create a new source program. The new version of source program has the same name as the input source program, with the prefix nl_. For example, if the input source program is named prog.c, the output source program is named nl_prog.c. You use this command to replace hard-coded messages (text strings identified by the strextract command) with calls to the catgets function and to create a source message catalog file. The source message catalog contains the text for each message extracted from your input source program. The strmerge command names the file by appending to the name of the input source program. For example, the source message catalog for the prog.c program is named prog.msg. You can use the source message catalog as input to the gencat command. At run time, the program reads the message text from the message catalog. By storing messages in a message catalog, instead of your pro- gram, you allow the text of messages to be translated to a new language or modified without the source program being changed. In the source-program argument, you name one or more source programs for which you want strings replaced. The strmerge command does not replace messages for source programs included using the #include directive. Therefore, you might want a source program and all the source programs it includes on a single strmerge command line. You can create a patterns file (as specified by patternfile ) to control how the strmerge command replaces text. The patterns file is divided into several sections, each of which is identified by a keyword. The keyword must start at the beginning of a new line, and its first character must be a dollar sign ($). Following the identifier, you specify a number of patterns. Each pattern begins on a new line and follows the regular expression syntax you use in the ed editor. For more information on the patterns file, see the patterns(4) refer- ence page. RESTRICTIONS
You can specify only one rewrite string for all classes of pattern matches. The strmerge command does not verify if the message text file matches the source file being rewritten. The strmerge command does not replace strings to files included with #include directive. You must run the strmerge command on these files separately. EXAMPLES
The following produces a message file prog.cat for a program called prog.c. % strextract -p c_patterns prog.c prog2.c % vi prog.str % strmerge -p c_patterns prog.c prog2.c % gencat prog.cat prog.msg prog2.msg % vi nl_prog.c % vi nl_prog2.c % cc nl_prog.c nl_prog2.c In this example, the strextract command uses the c_patterns file to determine which strings to match. The input source programs are named prog.c and prog2.c. If you need to remove any of the messages or extract one of the created strings, edit the resulting message file, prog.str. Under no condi- tions should you add to this file. Doing so could result in unpredictable behavior. You issue the strmerge command to replace the extracted strings with calls to the message catalog. In response to this command, strmerge creates the source message catalogs, prog.msg and prog2.msg, and the output source programs, nl_prog.c and nl_prog2.c. Before compiling the source programs, you must edit nl_prog.c and nl_prog2.c to include the appropriate catopen and catclose function calls. The gencat command creates a message catalog and the cc command creates an executable program. SEE ALSO
extract(1), gencat(1), strextract(1), trans(1), regexp(3), catopen(3), catgets(3), patterns(4) Writing Software for the International Market strmerge(1)
All times are GMT -4. The time now is 06:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy