The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Append to end of each line of file without a temp file. rorey_breaker Shell Programming and Scripting 4 04-03-2008 10:11 AM
How to append a Value to all the rows in a file dsshishya Shell Programming and Scripting 2 03-20-2008 05:04 PM
Append (cat) to beginning of file ? CBZ Shell Programming and Scripting 8 02-19-2008 01:26 AM
append file name contents to a target file gopskrish UNIX for Dummies Questions & Answers 2 10-27-2006 06:18 AM
Append a field to the end of each line of a file based on searching another file. ultimate Shell Programming and Scripting 2 03-29-2005 10:21 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-24-2007
ayhanne ayhanne is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 51
Append output to file

Hi,

I have a script below. It get's the data from the output of a script that is running hourly. My problem is every time my script runs, it deletes the previous data and put the current data. Please see output below. What I would like to do is to have the hourly output to be appended on the file like the expected output below. Please help me how to modify my script to do it. Thanks!


Output:
DateTime succDeliv failDeliv Subs SysFail Tot
2007-10-24_15H 12 1 43 0 1856

Expected output:
DateTime succDeliv failDeliv Subs SysFail Tot
2007-10-24_00H 12 13 43 6 1856
2007-10-24_01H 16 21 80 0 1780
2007-10-24_03H 0 8 56 9 1867
2007-10-24_04H 98 0 67 0 1909

Script:
#!/bin/ksh -f

######get date today############
ngayon=`TZ=GMT+1 date '+%Y-%m-%d'`
dateF=`TZ=GMT date '+%Y-%m-%d_%HH'`
outFayl="RSC-FinalStat-${ngayon}.txt"
workDir="/export/Stats"


printf "%-20s %-20s %-20s %-20s %-20s %-20s\n" DateTime succDeliv failDeliv Subs SysFail Tot > $workDir/$outFayl


cd $workDir
DateTime=dateF
succDeliv=`sed -n 2p $workDir/Stats_$dateF.txt`
failDeliv=`sed -n 4p $workDir/Stats_$dateF.txt`
AbsSubs=`sed -n 6p $workDir/Stats_$dateF.txt`
SysFail=`sed -n 8p $workDir/Stats_$dateF.txt`
Tot=`sed -n 10p $workDir/Stats_$dateF.txt`


printf "%-20s %-20s %-20s %-20s %-20s %-20s\n" $dateF $succDeliv $failDeliv $Subs $SysFail $Tot >> $workDir/$outFayl
 

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 01:17 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