| | |
Find info based on date
![]() |
•
•
Join Date: Feb 2006
Posts: 17
Reputation:
Solved Threads: 0
Hello everyone,
Given a list of output that looks like this (from NetBackup bpimagelist if any of you are familiar), I need to pick out the last full backup closest to the end of the quarter (3/30, 6/30, 9/30 12/31).
10/20/2006 21:24 INFINITY 146144 64213523 N Full Backup
10/13/2006 21:46 INFINITY 144120 60868157 N Full Backup
10/06/2006 21:22 INFINITY 148940 59931237 N Full Backup
09/23/2006 02:14 INFINITY 114239 57878059 N Full Backup
09/15/2006 21:31 INFINITY 137821 58463789 N Full Backup
09/01/2006 23:47 INFINITY 130842 57890925 N Full Backup
08/25/2006 21:34 INFINITY 120475 57706942 N Full Backup
08/11/2006 22:49 INFINITY 105830 54603266 N Full Backup
06/28/2006 23:37 INFINITY 110950 45103754 N Full Backup
In the example above, I would want to pull out the 6/28 and 9/23 backups.
I appreciate any help!
Given a list of output that looks like this (from NetBackup bpimagelist if any of you are familiar), I need to pick out the last full backup closest to the end of the quarter (3/30, 6/30, 9/30 12/31).
10/20/2006 21:24 INFINITY 146144 64213523 N Full Backup
10/13/2006 21:46 INFINITY 144120 60868157 N Full Backup
10/06/2006 21:22 INFINITY 148940 59931237 N Full Backup
09/23/2006 02:14 INFINITY 114239 57878059 N Full Backup
09/15/2006 21:31 INFINITY 137821 58463789 N Full Backup
09/01/2006 23:47 INFINITY 130842 57890925 N Full Backup
08/25/2006 21:34 INFINITY 120475 57706942 N Full Backup
08/11/2006 22:49 INFINITY 105830 54603266 N Full Backup
06/28/2006 23:37 INFINITY 110950 45103754 N Full Backup
In the example above, I would want to pull out the 6/28 and 9/23 backups.
I appreciate any help!
•
•
Join Date: May 2004
Posts: 178
Reputation:
Solved Threads: 10
try:
input file:
output:
Shell Scripting Syntax (Toggle Plain Text)
#!/bin/ksh export infile=filename filedate() { perl -e ' use Time::Local; $mytime = timelocal(0,$ARGV[4],$ARGV[3],$ARGV[1], $ARGV[0] - 1,$ARGV[2] - 1900); print "$mytime\n"; ' $1 $2 $3 $4 $5 } compare() { keep="None found" maxallowed=$1 minallowed=$2 result=$minallowed while read record do echo "$record" | tr -s '/' ' ' | tr -s ':' ' '| \ read mon day yr hr mins dummy filedate $mon $day $yr $hr $mins | read value if [[ $value -lt $minallowed || $value -gt $maxallowed ]] ; then continue fi if [[ $value -gt $result ]] ; then result=$value keep=$record fi done < $infile print "$keep" } # Q1 filedate 12 31 2005 23 59 | read min let min=$min+61 filedate 03 30 2006 23 59 | read limit compare $limit $min #q2 let min=$limit+61 filedate 06 30 2006 23 59 | read limit compare $limit $min #q3 let min=$limit+61 filedate 09 30 2006 23 59 | read limit compare $limit $min #q4 let min=$limit+61 filedate 12 31 2006 23 59 | read limit compare $limit $min
input file:
Shell Scripting Syntax (Toggle Plain Text)
10/20/2006 21:24 INFINITY 146144 64213523 N Full Backup 10/13/2006 21:46 INFINITY 144120 60868157 N Full Backup 10/06/2006 21:22 INFINITY 148940 59931237 N Full Backup 09/23/2006 02:14 INFINITY 114239 57878059 N Full Backup 09/15/2006 21:31 INFINITY 137821 58463789 N Full Backup 09/01/2006 23:47 INFINITY 130842 57890925 N Full Backup 08/25/2006 21:34 INFINITY 120475 57706942 N Full Backup 08/11/2006 22:49 INFINITY 105830 54603266 N Full Backup 06/28/2006 23:37 INFINITY 110950 45103754 N Full Backup
Shell Scripting Syntax (Toggle Plain Text)
kcsdev:/home/jmcnama> closest.sh None found 06/28/2006 23:37 INFINITY 110950 45103754 N Full Backup 09/23/2006 02:14 INFINITY 114239 57878059 N Full Backup 10/20/2006 21:24 INFINITY 146144 64213523 N Full Backup
![]() |
Similar Threads
- alexa ranking (Search Engine Optimization)
- Where do I find detailed hardware info? (Troubleshooting Dead Machines)
- vBulletin mod_rewrite (PHP)
- Problems With Xp Boot Loader (Windows NT / 2000 / XP)
- Mobility Radeon is Unstable (Windows NT / 2000 / XP)
- Cannot find #websitename.com error (Web Browsers)
- obtaining data info from device connected on com1 port (C++)
- where can i find a driver for a hitachi GD 2500 (Storage)
Other Threads in the Shell Scripting Forum
- Previous Thread: checking input
- Next Thread: Is recursion possible with strings command from command line?
| Thread Tools | Search this Thread |





