Working on Files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Working on Files
# 1  
Old 12-27-2011
Working on Files

Hi,

One of the program creating a file with the following information.

$cat a.txt
1, AAA, 234
$

and I wrote a script whenever any of the the file exists with data then it will send a email to me.

If I start the job second time, then the as per the logic it is sending the same data, I would like to write a script which will check if the same data is already sent in the previous mail then it should ignore and if any of the new records exists in the file then only the mail should go to the concerned person.

could you please help me on this.

I believe, after generating the file I may have to take the copy of this file into one more directory and I have to compare the data with previous file, I tried my ways but didn't worked. appreciate if you could help me on this.
# 2  
Old 12-27-2011
believe, after generating the file I may have to take the copy of this file into one more directory and I have to compare the data with previous file

Code:
 
diff a.txt /another/dir/a.txt && echo "No difference" || echo "Different"

Code:
#end of your script
cp a.txt /another/dir/a.txt

# 3  
Old 12-27-2011
one way:

Store the filesize in a temp file on each run.
On next run, read the filesize and compare with the current file.
If filesize same, dont send mail, else proceed further.
# 4  
Old 12-27-2011
Thank you for your reply.

Imagine if the file size is different but there may be chance that any of the record I may received from previous file.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Apache chown on its files not working

Hello, My apache user generate one file : # ls -lsa /tmp/reference_file.csv 76 -rwxrwxrwx 1 apache apache 69921 Aug 16 14:14 tmp/reference_file.csv the user and the group belong to apache, but when i am trying to change it : su -l apache -s /bin/bash -bash-3.00$ whoami apache... (7 Replies)
Discussion started by: cterra
7 Replies

2. Shell Programming and Scripting

Output, working with files. What is wrong?

I cannot figure out what is wrong.... I have 3 files with IP addresses: file1 134.123.3.236 file2 134.123.3.235 file3 134.123.5.237 I type "prob1 Oops x2x3x4". Then my code creates file with name Oops and first line x2x3x4. Moreover, my code generate IP and it gives to file Oops as a second... (8 Replies)
Discussion started by: Manu1234567
8 Replies

3. Shell Programming and Scripting

Working with files that are named with a timestamp

So I have a script that runs an ls on a given directory and looks for files with a timestamp that has the current hour in it and then does work with the files that it discovers DATE=`date +'%y%m%d%H'` HOSTIS=`hostname` #EMAIL NOTIFICATION ALS EMAIL=address@server.com # if ; then ... (5 Replies)
Discussion started by: os2mac
5 Replies

4. Shell Programming and Scripting

[awk] working with two files

Hello guys, I have little to no experience working with two files in awk and hope you can help me with a problem that may be easy for you to solve... awk -v cut1="$var1" -v cut2="$var2" '{split($0, arr1); for(i=1;i<=NF;i++) if (arr1 < cut1) print arr1, NR, i}' file1 file2 The above code is... (4 Replies)
Discussion started by: origamisven
4 Replies

5. Shell Programming and Scripting

Problem while working with multiple files

Dear friends, I am working with two files named g1.txt and g2.txt....g1.txt is my main file in which it contains following data #per_no permissionname permission command 1|HideCDrive, | : REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v... (1 Reply)
Discussion started by: jalpasoni
1 Replies

6. Shell Programming and Scripting

Working with log files

I wrote a bash script to extract a few Items like the IP addresses that makes the most number of connection attempts, now I want to limit all of this within a time range , lets say the last X days/hours. Example of what I wrote : -G: Which IP address makes the most number of connection... (2 Replies)
Discussion started by: melisa.zand
2 Replies

7. AIX

exclude files not working

HI, I have upgraded nim master and client to TL8,SP6. Now when the mksysb backup ran from master,it is not excluding directories specified in /etc/exclude.rootvg in the client.Instead,mksysb is getting created for all the file systems in the rootvg. This problem only appeared after the TL... (3 Replies)
Discussion started by: to_bsr
3 Replies

8. UNIX for Dummies Questions & Answers

RedirectMatch not working for files

Hi I am trying to redirect all webpages within a directory on my site to another website. I can only get this to work for directories only, not actual files. The following scenarios work: http://www.mysite.com/folder1/folder3 redirects to http://www.newsite.com/redirectpage.jsp ... (0 Replies)
Discussion started by: geoscience
0 Replies

9. Shell Programming and Scripting

working with files

Hi All, Can u plz tell me how to ensure row count. input file /app/PNYCOINF01/opera/operaprd/Data/SENTRY_BSL2_COLLRECEIVEPOS_AM_20070716.dat checkFile: The input file exists checkFile: Checking for existing copy of output file... (4 Replies)
Discussion started by: balireddy_77
4 Replies

10. Shell Programming and Scripting

bash script working for small size files but not for big size files.

Hi, I have one file stat. Stat file contents are as follows: for example. H50768020040913,00260100,507680,13,0000000643,0000000643,00000,0000 H50769520040808,00260100,507695,13,0000000000,0000000000,00000,0000 H50770620040611,00260100,507706,13,0000000000,0000000000,00000,0000 Now i... (1 Reply)
Discussion started by: davidpreml
1 Replies
Login or Register to Ask a Question