Sponsored Content
Top Forums Shell Programming and Scripting Redirect and append output to different files Post 303046226 by RudiC on Tuesday 28th of April 2020 06:07:06 AM
Old 04-28-2020
As ususal: what OS and shell versions?


In (recent) bash, set the pipefail option:
Code:
$ set -o pipefail
$ ls -l fxxxx | tee -a file2 | tee file1
ls: cannot access 'fxxxx': No such file or directory
$ echo $?
2

This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Append and redirect

Can somebody please explain to me what redirection (>) and append are? What is the difference between > and >>? Thank-you (1 Reply)
Discussion started by: Anna
1 Replies

2. 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

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

output redirect

Hi i am compiling a source code by make command. i want to redirect the output of make to a file but at the same time i want to see the output in terminal. how to do this ?. please suggest your idea. thanks in advance. Saravana ---------- Post updated at 05:24 PM ----------... (2 Replies)
Discussion started by: tsaravanan
2 Replies

6. 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

7. Shell Programming and Scripting

Redirect Output and Error in 2 different files

hi, i want to redirect my output & error if generated to two different files. I have written the code for redirecting the output, i dnt have ne idea how to go abt it for errors. I tried spooling which was given in one of the threads on this forum.But it didn't work.The script i wrote as a lot... (4 Replies)
Discussion started by: bankimmehta
4 Replies

8. 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

9. 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

10. UNIX for Dummies Questions & Answers

How to append a string by cat and redirect to other file?

Hi, when I do cat for kernel parameters cat /proc/sys/kernel/sem >> /etc/sysctl.conf 4096 4096 32 128 The above command working with out any doubt but I want to pass it like below, need to append "kernel.sem =" and pass it to /etc/sysctl.conf kernel.sem = 4096... (2 Replies)
Discussion started by: stew
2 Replies
tee(1)								   User Commands							    tee(1)

NAME
tee - replicate the standard output SYNOPSIS
/usr/bin/tee /usr/bin/tee [-ai] [file]... ksh93 tee [-ail] [file]... DESCRIPTION
/usr/bin/tee /usr/bin/tee copies standard input to standard output, making a copy in zero or more files. tee does not buffer its output. The options determine if the specified files are overwritten or appended to. ksh93 The tee built-in in ksh93 is associated with the /bin and /usr/bin paths. It is invoked when tee is executed without a pathname prefix and the pathname search finds a /bin/tee or /usr/bin/tee executable. tee copies standard input to standard output and to zero or more files. The options determine whether the specified files are overwritten or appended to. The tee utility does not buffer output. If a write to a file fails, tee continues to write to other files although it exits with a non-zero exit status. The number of file operands that can be specified is limited by the underlying operating system. OPTIONS
/usr/bin/tee The following options are supported by /usr/bin/tee: -a Appends the output to the files rather than overwriting them. -i Ignores interrupts. ksh93 The following options are supported by the tee built-in command in ksh93: -a Appends the output to the files rather than overwriting them. --append -i Ignores SIGINT signal. --ignore-interrupts -l Sets the standard output to be line buffered. --line-buffer OPERANDS
The following operands are supported: file A path name of an output file. Processing of at least 13 file operands are supported. USAGE
See largefile(5) for the description of the behavior of tee when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes). ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of tee: LANG, LC_ALL, LC_CTYPE, LC_MES- SAGES, and NLSPATH. EXIT STATUS
/usr/bin/tee The following exit values are returned by /usr/bin/tee: 0 The standard input was successfully copied to all output files. >0 The number of files that could not be opened or whose status could not be obtained. ksh93 The following exit values are returned by tee in ksh93: 0 Successful completion. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: /usr/bin/tee +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ |Standard |See standards(5). | +-----------------------------+-----------------------------+ ksh93 +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |Interface Stability |See below. | +-----------------------------+-----------------------------+ The ksh93 built-in binding to /bin and /usr/bin is Volatile. The built-in interfaces are Uncommitted. SEE ALSO
cat(1), ksh93(1), attributes(5), environ(5), largefile(5), standards(5) SunOS 5.11 20 Nov 2007 tee(1)
All times are GMT -4. The time now is 04:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy