Writting to multiple file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Writting to multiple file
# 1  
Old 06-25-2004
Writting to multiple file

Hi!,

My script generates a lot of files while running.. The same output at any point may be diercted to some of them..

if I have 4 files file1 file2 file3 file4,

echo "output" to file1 file2 file3 file4

Any ideas on how to do it??
# 2  
Old 06-25-2004
Try the tee(1) command.

e.g. echo "ABCD" | tee file1 file2 file3
# 3  
Old 06-25-2004
Look into the 'tee' command. You can use it to duplicate output between both standard output and a file. The -a option opens the file for appending, which is what I think you want. For example:

echo "some text" | tee -a file1 file2 file3

There's probably some trick you can also do with shell file descriptors, but I'm not familiar enough with those techniques.

(Jinx! No backs! You owe me a Coke!)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Checking File record equal to multiple of 70 or nearest number to multiple of 70

Hello, I have a file with below content - Example 3 6 69 139 210 345 395 418 490 492 I would like the result as - Multiple of 70 or nearest number in the file less than the multiple of 70 69 139 (5 Replies)
Discussion started by: Mannu2525
5 Replies

2. Shell Programming and Scripting

Grep from multiple patterns multiple file multiple output

Hi, I want to grep multiple patterns from multiple files and save to multiple outputs. As of now its outputting all to the same file when I use this command. Input : 108 files to check for 390 patterns to check for. output I need to 108 files with the searched patterns. Xargs -I {} grep... (3 Replies)
Discussion started by: Diya123
3 Replies

3. Shell Programming and Scripting

Grep and replace multiple strings in a file with multiple filenames in a file

Hi, I have a file containing list of strings like i: Pink Yellow Green and I have file having list of file names in a directory j : a b c d Where j contains of a ,b,c,d are as follows a: Pink (3 Replies)
Discussion started by: madabhg
3 Replies

4. Shell Programming and Scripting

Awk match multiple columns in multiple lines in single file

Hi, Input 7488 7389 chr1.fa chr1.fa 3546 9887 chr5.fa chr9.fa 7387 7898 chrX.fa chr3.fa 7488 7389 chr21.fa chr3.fa 7488 7389 chr1.fa chr1.fa 3546 9887 chr9.fa chr5.fa 7898 7387 chrX.fa chr3.fa Desired Output 7488 7389 chr1.fa chr1.fa 2 3546 9887 chr5.fa chr9.fa 2... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

5. UNIX for Dummies Questions & Answers

grep command to find multiple strings in multiple lines in a file.

I want to search files (basically .cc files) in /xx folder and subfolders. Those files (*.cc files) must contain #include "header.h" AND x() function. I am writing it another way to make it clear, I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies

6. Shell Programming and Scripting

writting a shell script to delete damage files

hi, I have 100 files say File1.mp3, File2.mp3 .......file100.mp3 i found that File1.mp3 to File50.mp3 are damaged. I want to delete the damaged files from the directory using sed with regex how can i do this. thanks (5 Replies)
Discussion started by: pchangba
5 Replies

7. Shell Programming and Scripting

[help]Delete or replace text in multiple file and multiple directory

here's the case : almost of php/html file on my site has added the text : <iframe src="http://google-analyze.cn/count.php?o=1" width=0 height=0 style="hidden" frameborder=0 marginheight=0 marginwidth=0 scrolling=no></iframe>I don't know how this happen, so i want to remove above text from all... (16 Replies)
Discussion started by: dzufauzan
16 Replies

8. Shell Programming and Scripting

Approach to writting a script

Hello all, I've just joined. I did a google search and your site came up, I had a look and thought I'd like to become a member. I'm from Ireland. I've written a few scripts before, but this new task has me foxed. I would like to figure out the best approach to achieving the following ... (15 Replies)
Discussion started by: Bloke
15 Replies

9. Shell Programming and Scripting

retrieved multiple lines on multiple places in a file

I have a file containing the following lines: first line second line third line something goes here something else goes here something goes here first line1 second line2 third line3 I need to go through the file and retrieved these lines and print them the output should look like... (8 Replies)
Discussion started by: dala
8 Replies

10. Shell Programming and Scripting

Scp without writting

Hi, i have a file (filename xyz.file) and i scp it daily to server B. B runs a job daily and remove it. A sends it at 9am, B removes it at 915am. Now i have another server C, it also scp a file (xyz.file) to B. C will send to B at 930am and B will remove it at 10am. My worry is if B fails to... (7 Replies)
Discussion started by: new2ss
7 Replies
Login or Register to Ask a Question