Sponsored Content
Top Forums Shell Programming and Scripting how to check if a new line has been added to a file? Post 302301207 by Shahul on Thursday 26th of March 2009 07:08:51 AM
Old 03-26-2009
Hi,
i m not sure exactly what you want..suppose if you want to know only when there is new line comes in your log ...then below will work...

i did small change in your script..

Code:
OUTPATH=/home/out
PARMFILE=$OUTPATH/jobcount_test.txt
LOG=$OUTPATH/job_count_monthlymail_log.txt
HLOG=$OUTPATH/job_count_monthlymail_hlog.txt
#
echo " started at $(date)" > $LOG
#
Linecount=`wc -l $PARMFILE|awk '{print $2}'`

while [[ $Linecount -le 2 ]]
do
   body_msg=`tail -1 $PARMFILE`
   mailx -s "$body_msg" jarrathy@notes < $body_msg
done
##
echo " ended at $(date)" >> $LOG
cat $LOG >> $HLOG

Thanks
SHa

Last edited by Franklin52; 03-26-2009 at 08:34 AM.. Reason: adding code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

check line in a file

Hi all, How do we check in a file whether a line started with KEYWORD2 is right after the line started with KEYWORD1 for example, this file content: Abcdef gsh iasdi 94945 9085095 lksdjlkj KEYWORD1 skljfi slakjfoi ' opiport sdfl KEYWORD2 ksjflsk jfasope jkdfsk393 89374982 23 ... (3 Replies)
Discussion started by: fongthai
3 Replies

2. UNIX for Dummies Questions & Answers

extran NUll character added after end of line "\n"

Hi All, I am facing a strange situation and want to find why it is occuring . When i convert the whole line into Hexadecimal character i can find the junk value after new line (\n) . If i look in binary mode it is not visible. PLease let me know how possible the junk character is added... (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

3. Shell Programming and Scripting

Read last line of file to check for value

Folks How best to read the last line of a file, to check for a particular value? This is the last line of my file...... 00000870000002000008 0000000020000 ......I need to check that this line contains '70' in positions 7 and 8, before I continue processing. Regards ... Dave (12 Replies)
Discussion started by: daveaasmith
12 Replies

4. Shell Programming and Scripting

check line by line in a file

Hi there How can I check line by line in a file? I need to compare the first value with the second to know if they are equal. If those values are equal, I require to send "TRUE" to the output or "FALSE" otherwise until the complete file has been read. Thank you (6 Replies)
Discussion started by: loperam
6 Replies

5. Shell Programming and Scripting

one line command to check file existence and FTP it

Hi all, I need a batch script to Check for existence of file say i check for files with extension xml.done in C:\Myfile.(This folder contains .xml file and its corresponding .done files) If the .done file exists then it should FTP the corresponding .xml file to UNIX. Is this possible to do... (6 Replies)
Discussion started by: Codesearcher
6 Replies

6. Shell Programming and Scripting

How to check for a character at last line of the file?

this is the csv file. i want to check the last line contains the character N. Record Type#Batch Job ID#Batch Number#FileCreation Date#FileCreation Time#Production/Test Fileindicator#File Character H#0002#0002#20100218#17.25#P#barani Record Type#A#B#C#D#E#F#G#H#J#K#L... (5 Replies)
Discussion started by: barani75
5 Replies

7. Shell Programming and Scripting

Added new line before a specific pattern problem asking

Input file: Sample1 Type pattern 842 3150 Sample1 Type range 842 3150 Sample1 Type pattern 842 1127 Sample1 Type option 842 1127 Sample1 Type length 1483 1603 Sample1 Type pattern 1483 1603 Sample1 Type length 1698 1747 Sample1 Type option 1698 1747 Sample1 Type length 1868 1935 Sample1... (13 Replies)
Discussion started by: patrick87
13 Replies

8. Shell Programming and Scripting

Need to echo a text where a (.) is added to the end of line during on-going copy or ftp

Hello All, I would like to create a script to echo a text where a (.) dot is added every 2 seconds to the end of this text (with a limit of 10 dots) as long as a file copy or ftp is ongoing and once the copy is finished it adds "done" to the end of this text line. please see the below example: ... (6 Replies)
Discussion started by: Dendany83
6 Replies

9. Shell Programming and Scripting

Execution problems when added two same content in each line

Input: >sample_1 ASDAFDGSGH >sample_2 ASDFDAFDSFS >sample_3 ASDAFDAFDFD >sample_4 ASDFDFDSFDSF . Desired output >sample_1 ASDAFDGSGHXX >sample_2 ASDFDAFDSFSXX >sample_3 ASDAFDAFDFDXX (2 Replies)
Discussion started by: patrick87
2 Replies

10. UNIX for Dummies Questions & Answers

Check for empty line at end of a dynamic header in each file

Hi Folks, I have a requirement to develop a shell script. PFB my requirement, Requirement: I need to check an empty line after the end of each header in respective file and if a empty line is present simply echo file OK and if empty line is not present echo "Adding empty line" and add an... (6 Replies)
Discussion started by: tpk
6 Replies
FPRINTF(3)								 1								FPRINTF(3)

fprintf - Write a formatted string to a stream

SYNOPSIS
int fprintf (resource $handle, string $format, [mixed $args], [mixed $...]) DESCRIPTION
Write a string produced according to $format to the stream resource specified by $handle. PARAMETERS
o $handle -A file system pointer resource that is typically created using fopen(3). o $format - See sprintf(3) for a description of $format. o $args - o $... - RETURN VALUES
Returns the length of the string written. EXAMPLES
Example #1 fprintf(3): zero-padded integers <?php if (!($fp = fopen('date.txt', 'w'))) { return; } fprintf($fp, "%04d-%02d-%02d", $year, $month, $day); // will write the formatted ISO date to date.txt ?> Example #2 fprintf(3): formatting currency <?php if (!($fp = fopen('currency.txt', 'w'))) { return; } $money1 = 68.75; $money2 = 54.35; $money = $money1 + $money2; // echo $money will output "123.1"; $len = fprintf($fp, '%01.2f', $money); // will write "123.10" to currency.txt echo "wrote $len bytes to currency.txt"; // use the return value of fprintf to determine how many bytes we wrote ?> SEE ALSO
printf(3), sprintf(3), sscanf(3), fscanf(3), vsprintf(3), number_format(3). PHP Documentation Group FPRINTF(3)
All times are GMT -4. The time now is 05:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy