I am not expert in unix shell scripting but able to write simple one. So please help me to implement following functionality.
There are two directories :
1) /home/guptar/wrk
2) /home/guptar/arc
I need to write a script "arch.sh" which would be executing every 10 minutes through cron. If in last ten minutes there is file reached in wrk directory then script will send a mail and will copy that file to arc folder.
File name convention is prn<counter>.txt.
I know that mtime or ctime can be used but not sure how can I do this?
Why are you willing to deal with than 10 min constraint ?
Can't you just tell your script to archive all the prn<counter>.txt files ?
Since your script will be scheduled every 10 minutes in the crontab it will just pickup those files that have meanwhile been created (since the last run).
If you are afraid to harvest a file that is currently being updated you can pick up all but not the last one (or all but not the "n" last, just adapt the tail or head number to skip).
Below, some examples to skip the last one.
or ... if you want to process them in the same order they were created (and if your head version does support the negative value of -n option):
of course this can be enhanced (adapt with you own path, make a copy instead of a move, check the status of the copy or perform some checksum operation before deleting the original file etc ...)
Hi,
I am currently using the find below to remove old files. I am redirecting the listing to a file and then use a while-loop and do a rm
cd ${directory}
find . \( ! -name . -prune \) \( -type f -name "*.trc" -mtime +10 \) | sed 's#^./##' | sed "s#^#${directory}/#" 2>/dev/null | tee -a... (4 Replies)
I need assistance with following requirement, I am new to Unix.
I want to do the following task but stuck with file creation date(sysdate)
Following is the requirement
I need to create a script that will read the abc/xyz/klm folder and look for *.err files for that day’s date and then send an... (4 Replies)
Hi all ,
I'm new to unix
I have a checked project , there exists a file called xxx.config .
now my task is to find all the files in the checked out project which references to this xxx.config file.
how do i use grep or find command . (2 Replies)
Hello,
Can anybody please tell me the command to find out the filesystem or a file which is consuming larger disk space sing i want to find out the file and want to compress it
please help me out
any help would be appreciated (6 Replies)
I need to find whether there is a file named vijay is there or not in folder named "opt" .I tried "ls *|grep vijay" but it showed permission problem.
so i need to use find command (6 Replies)