hi every one. one of my friends has writen this script and send it to me. this script can find files that add-delete-modify and also send an alert by email
i'm not catch all part of it.
can anyone explain me how this work
If it is working, it's just what you asked your friend for.
Why don't you ask your friend?
Next time, be more precise which part you do not understand instead, thanks.
Use bash explicit as interpreter to run this script
Define 3 variables with a file name.
Renames the start file to the name of the end file. If it already exists, it is overwritten. Saves the data in the file from the previous run to b.txt so they are not lost and can be compared with actual data.
Find files in directory /home that are not older than 5 minutes and write their path and name into the file a.txt.
Find the lines that are different from the old file b.txt and write them to the file c.txt.
Count the number of different lines.
Check if the file c.txt exists and has a size greater 0.
If this is the case, tell cat to not accept any switches and send a mail with the subject "Modified files..." where the mail's body is the cat'ed different lines to root.
Last edited by zaxxon; 09-16-2013 at 02:31 PM..
Reason: messing around with code tags
? I do not understand that question. All of this code is executed by the bash shell. The part you mention is just a definition of strings as values to variable names. These 3 lines do actually not touch the files in any way. This comes in the following lines.
Hi All,
I've created 2 files
touch -t 201309101234 aa10
touch -t 201309111234 aa11
Exact 60 days before from today date is SEPT 12th . As per the following command as i gave +60 means the files which were created before sept12th should be deleted
find /etc/logs/*aa* -type f -atime +60... (5 Replies)
Hi,
I want to delete all the log files that was created on year 2008. My command is not working. Any idea?
find . -name '*.log' -mtime 1460 -exec ls -lt {} \;
Thank you. (2 Replies)
I have a task, I usually do manually, but with growing responsibilities I tend to forget to do this weekly, I want to write a script that automates this, but I cant seem to work it out in my head, I have the shell of it out, but need help, and you guys have helped me with EVERY problem I have... (5 Replies)
This is a real world problem so I think you might found this interesting. We have servers which are shared by multiple team members. Each team member has its own user id and home directory. Now with time each user starts creating files which in end caused the disk to be full.
Now for creating a... (5 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Need to make a script, to remove all empty files and folders from current category.
It also should show the name... (2 Replies)
I have a directory where lot of "gzip" files are dropped in every 5 minutes. There is an application which will process these gzip and move it to another directory but will leave a gzip.out file with lot of output data.
I need to remove all the outfiles except for the one which is being... (1 Reply)
Hello Experts,
I m newbie. Could u pls help me to write script on Sun solaris-
I have backup directory "/var/opt/backup/" where files are backed up in different directory "backup1" "backup2" "backup3".
I want to write a shell script which i will put in crontab and daily midnight it will... (1 Reply)
UPDATE: Sorry, disregard this.
It did work, I made a mistake; I just shouldn't have been using maxdepth.
I do think it is good to know, however, that
find | grep '#' | xargs rm
will "clean up" funnily named files in a directory. Of course, some of those funnily named files are there... (0 Replies)