Find and copy files based on todays date and search for a particular string
Hi All,
I am new to shell srcipting.
Problem :
I need to write a script which copy the log files from /prod/logs directory based on todays date like (Jul 17) and place it to /home/hzjnr0 directory and then search the copied logfiles for the string "@ending successfully on Thu Jul 17". If this string is not found then a mail will be sent to specific user.
The logs are generated everyday in a /prod/logs directory location and with datestamp like (Jul 10).
You can start with reading about globbing, cp, grep and mailx.
Here are few examples to help you start:
The following command will copy all files, name starting with "Jul17" from /prod/logs and paste them in /home/hzjnr0
grep will look for required string in a file.
mailx will send an email
Thanks for your reply, appreciate it.
But i am trying to write a script for doing this. Also my logfiles name didn't start with current date.
They are like a.log, b.log with todays timestamp.
so
is not helping.
Also by
i can search for one file but i was trying to search for the same string in multiple log files
so this is not resolved the problem.
if any oneliner of find command can be used plz advice.
I have tried this
but this is not copying the files based on today's timestamp.
Last edited by Franklin52; 07-17-2012 at 09:44 AM..
Reason: Please use code tags for data and code samples, thank you
Experts,
Need your support for this awk script.
we have only one input file, all these column 1 and column 2 are in same file and have to do lookup for values in one file(column1 and column2) but output we need in another file
Need to grep row whose string contains 9K from column 1. When found... (6 Replies)
Hi Team,
I'm new to unix and i have a requirement to copy or move files from one directory to another based on current date mentioned in the .zip file name. Note that i need to copy only the recent zip file. please help me with the code
i tried the code as:
#! /usr/bin/sh
find... (3 Replies)
Hi i need to keep todays files based on timestamp and archive the remaining files
ex:
Managerial_Country_PRD_20150907.csv
Managerial_Country_PRD_20150907.csv
Managerial_Country_PRD_20150906.csv
Managerial_Country_PRD_20150905.csv (6 Replies)
My unix version is IBM AIX Version 6.1
I tried google my requirement and found the below answer,
find . -newermt “2012-06-15 08:13" ! -newermt “2012-06-15 18:20"
But newer command is not working in AIX version 6.1 unix
I have given my requirement below:
Input:
atr files:
... (1 Reply)
hi all,
How to compare two files whether they are same are not...? like i had my input files as 20141201_file.txt and 20141130_file2.txt
how to compare the above files based on date .. like todays file and yesterdays file...? (4 Replies)
Hi All,
I am very new to UNIX and I have tried this for a longtime now and unable to crack it....
There is a file that is continuously updating. I need to search for the string and find the date @ which it updated every day.....
eg:
String is "work started"
The log entry is as below:
... (1 Reply)
Hi, I have a requirement to copy files from a windows network drive to a Linux server using shell script based on the last created date.
Ex:
FileName CreatedDate/Time
F1 05-01-2012 3:00 PM
F2 05-01-2012 3:15 PM
F3 05-01-2012 2:00 PM
When i run the shell script... (1 Reply)
Hello,
I am quite new to unix/shell and want to write a script using bash which will process the files.
Basically i want to search files having name as "date+hostname+somestring.out"
i am using below variables and then will use them in find command :-
TODAY_DATE=$('date +%d')... (5 Replies)
Hi all
i am having so many files in my directory.Is there any option
to copy files based on date.
example
i am having file this
-rw-rw-r-- 1 ram user 1 Feb 2 17:12 abc
-rw-rw-r-- 1 ram user 1 Feb 2 17:12 bnw
-rwxrwxr-x 1 ram user 21122 Feb 4... (3 Replies)
How to copy files from a location to a directory <YYMM> based on last modification date? This will need to run daily.
I want to copy those file for May to 0905 and Jun to 0906.
Appreciate your guidance.:) Thanks.
-rw-rw-rw- 1 ttusr tgrp 4514 May 29 21:49 AB24279J.lot_a... (17 Replies)