The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
retrieved multiple lines on multiple places in a file dala Shell Programming and Scripting 8 03-14-2008 03:28 PM
Multiple file handling rochitsharma UNIX for Advanced & Expert Users 8 04-30-2007 11:21 AM
Scp without writting new2ss Shell Programming and Scripting 7 07-18-2006 06:59 AM
Help with multiple file rename - change case of part of file name steve7 UNIX for Dummies Questions & Answers 7 06-30-2005 02:41 PM
Multiple file instances gozer13 UNIX for Dummies Questions & Answers 1 12-29-2004 07:08 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-25-2004
jyotipg jyotipg is offline
Registered User
  
 

Join Date: Oct 2001
Location: Bangalore
Posts: 95
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 (permalink)  
Old 06-25-2004
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
Try the tee(1) command.

e.g. echo "ABCD" | tee file1 file2 file3
  #3 (permalink)  
Old 06-25-2004
anarchie anarchie is offline
Registered User
  
 

Join Date: May 2004
Location: Hawaii
Posts: 37
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!)
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:13 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0