Sponsored Content
Top Forums Shell Programming and Scripting script to view files based on date Post 85372 by krahuliyer on Wednesday 5th of October 2005 04:10:15 AM
Old 10-05-2005
Help with the script of day before yesterday

Quote:
Originally Posted by vino
Here is a script for you.

Code:
#! /bin/sh
# krah.sh
[ -z $1 ] && echo "Defaulting to $(date +%F)" && DATE=$(date +%F) || DATE="$1"

touch -d "$1" /tmp/OLD
touch -r /tmp/OLD -F 86400 /tmp/NEW
find . -name '*' -newer /tmp/OLD ! -newer /tmp/NEW ! -size 0

rm -f /tmp/OLD /tmp/NEW

You should run it in the following format
Code:
./krah.sh YYYY-MM-DD

If you dont provide anything, then the current date will be picked up.

Vino


There is a problem with this.. I am getting an error like "./Script.sh: cannot execute".. I dont know why it is happening.. CAn u help or suggest something?


This is the exact thing thats being shown (my file is called Script.sh):

$ Script.sh
ksh: Script.sh: not found
$ ./Script.sh
ksh: ./Script.sh: cannot execute
$ ls -lt
total 1
-rw-r----- 1 BTBDEV1 dba 227 Oct 5 13:46 Script.sh

$ vi Script.sh
"Script.sh" 5 lines, 227 characters
1 [ -z $1 ] && echo "Defaulting to $(date +%F)" && DATE=$(date +%F) || DAT
E="$1"
2 touch -d "$1" /tmp/OLD
3 touch -r /tmp/OLD -F 86400 /tmp/NEW
4 find . -name '*' -newer /tmp/OLD ! -newer /tmp/NEW ! -size 0
5 rm -f /tmp/OLD /tmp/NEW
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
:q
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Remove files based on date

I am trying to write a shell script that will remove files in a directory based on the date. For instance, remove all files older than yesterday. Any ideas? (4 Replies)
Discussion started by: hshapiro
4 Replies

2. Shell Programming and Scripting

Count of files based on date?

Hi Friends, Can anyone help me with this: To get the count of files that are existing in a directory created on a perticular date like in the example (01/08) .(having same pattern for the filename) ex: FileName Creted Date FILE001 01/08/2007 FILE005 ... (6 Replies)
Discussion started by: sbasetty
6 Replies

3. Shell Programming and Scripting

script to search context from 2 files based on date and name

Please Close thread- Thank You. (1 Reply)
Discussion started by: ezmethod
1 Replies

4. Shell Programming and Scripting

Need script to select multiple files from archive directory based on the date range

hi all, here is the description to my problem. input parameters: $date1 & $date2 based on the range i need to select the archived files from the archived directory and moved them in to working directory. can u please help me in writing the code to select the multiple files based on the... (3 Replies)
Discussion started by: bbc17484
3 Replies

5. Shell Programming and Scripting

Deleting the files based on the date's

I have to write one script which will delete the files in the below passion. If today is 17-Feb-2010 then the script delete only 17-JAN-2010 files from the directory. Could you please help me, How will I delete the files when the year is leap year, if today is 30th Mar 2010 then how will... (1 Reply)
Discussion started by: kandi.reddy
1 Replies

6. UNIX for Dummies Questions & Answers

view gzipped files with name file.gz.$DATE on a Solaris box (without unzipping first)

Hi Howto view gzipped files with name file.gz.$DATE on a Solaris box (without unzipping first) $ ls -lrt total 4477 -rwxrwxr-x 1 oracle dba 569745 Apr 4 19:45 4_person2profileCon.txt.gz.04.04.11* -rwxrwxr-x 1 oracle dba 3783 Apr 4 19:45... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

7. Shell Programming and Scripting

How to view files from a specific date/day

I wan to view files in a directory of a specific date. For example a log directory has log files . I want to view the list of the files which were generated on 01-May-2011. Is there any option/proces to perform it?? (1 Reply)
Discussion started by: mady135
1 Replies

8. UNIX for Dummies Questions & Answers

Script moving files based on date

Hi, I need a script that moves files based on date to a folder. The folder should be created based on file date. Example is : Date file name ----- -------- Oct 08 07:39 10112012_073952.xls Oct 09 07:39 10112012_073952.xls Oct 10 07:39 ... (6 Replies)
Discussion started by: rockingvj
6 Replies

9. Shell Programming and Scripting

Script to determine Date,TotalFile,total size of file based on date

I have file listed like below -rw-r--r--+ 1 test test 17M Nov 26 14:43 test1.gz -rw-r--r--+ 1 test test 0 Nov 26 14:44 test2.gz -rw-r--r--+ 1 test test 0 Nov 27 10:41 test3.gz -rw-r--r--+ 1 test test 244K Nov 27 10:41 test4.gz -rw-r--r--+ 1 test test 17M Nov 27 10:41 test5.gz I... (5 Replies)
Discussion started by: krish2014
5 Replies

10. UNIX for Dummies Questions & Answers

Find the count of files by last created date based on the given date range

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)
Discussion started by: yuvaa27
1 Replies
ATSADC(1)							       local								 ATSADC(1)

NAME
atsadc, atsa1, atsaftp, atsahttp -- counter-collection SYNOPSIS
atsadc [ t n ] [ ofile ] atsa1 [ t n ] atsaftp atsahttp DESCRIPTION
System activity-data can be gathered on special request of a user [see atsar(1) ] or automatically, on a routine basis, as described here. Usually the kernel maintains statistical counters that are incremented as various system actions occur. These include counters for CPU uti- lization, disk utilization, memory utilization and various network statistics. The program atsadc and the shell-script atsa1 are used to collect, save, and process these counters. The program atsadc (the data collector) samples system data n times with an interval of t seconds between samples, and writes in binary format to ofile or (default) to standard output. The sampling interval t should be greater than 1 second. If t and n are omitted, a special reset-record is written. This facility is used when booting to a multi-user state, to mark the time at which the counters restart from zero. For example, the reset-mark can be added to the daily data by the command: /usr/local/bin/atsadc /var/log/atsar/atsa`date +%d` Note that this entry is written to the /etc/rc.d/init.d/atsar file. The shell-script atsa1 is used to collect and store data in the binary file /var/log/atsar/atsadd where dd is the current day of the month. The arguments t and n cause records to be written n times at an interval of t seconds, or once if omitted. Furthermore this script takes care that log-files older than a week are removed once a day. A file containing following entries should be added to the /etc/cron.d directory to produce records every 20 minutes during working hours and hourly otherwise: 0 * * * 0-6 root /usr/local/bin/atsa1 20,40 8-17 * * 1-5 root /usr/local/bin/atsa1 See crontab(1) for details. The shell-script atsaftp counts the new transfers registered in the FTP-logfile(s) since the previous time this script was activated; the new counters are stored in the /var/log/atsar/ftpstat file in ASCII-format. The names of the FTP-logfiles to be watched are specified in the /etc/atsar.conf configuration-file. The shell-script atsahttp counts the new transfers registered in the HTTP-logfile(s) since the previous time this script was activated; the new counters are stored in the /var/log/atsar/httpstat file in ASCII-format. The names of the HTTP-logfiles to be watched are specified in the /etc/atsar.conf configuration-file. Both scripts must be activated just before the program atsadc is started, which also collects these counters. FILES
/var/log/atsar/atsadd Daily data file, where dd are digits representing the day of the month. SEE ALSO
atsar(1), crontab(1) AUTHOR
Gerlof Langeveld, AT Computing (gerlof@ATComputing.nl) AT Computing July 2004 ATSADC(1)
All times are GMT -4. The time now is 05:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy