Table with no of files every hour


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Table with no of files every hour
# 1  
Old 02-24-2011
Table with no of files every hour

Hello,
In a HP-UX system we receive several files evry hour.
The file is in the format filename+hour e.g:
Code:
sv00
sv01
sv02
sv03
sv04
sv05
sv06
sv07
sv08
sv09
sv10
sv11
sv12
sv13
sv14
sv15
sv16
sv17
sv18
sv19
sv20
sv21
sv22
sv23
hr00
hr01
hr02
hr03
hr04
hr05
hr06
hr07
hr08
hr09
hr10
hr11
hr12
hr13
hr14
hr15
hr16
hr17
hr18
hr19
hr20
hr21
hr22
hr23
...
...

Is it possible to create a report that will look like:

Code:
FILENAME 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
hr OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK X OK
sv OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK OK
...
...

OK when file found, X when nofile found

Please suggest ways to do it.

PS I am not very familiar with awk :-(
Thank you in advance

Last edited by Franklin52; 02-25-2011 at 03:43 AM.. Reason: Please use code tags
# 2  
Old 02-24-2011
Huge oneliner:
Code:
perl -ne '/(\D+)(\d+)/;$a{$1}{int($2)}=1;END{print "FILENAME ";for ($i=0;$i<=23;$i++){print "$i "};print "\n";for $f (keys %a){print "$f ";for ($i=0;$i<=23;$i++){if (exists $a{$f}{$i}){print "OK "} else {print "X "}}print "\n"}}' filenames

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 02-24-2011
Another one -

Code:
$
$ # list all files in the current directory that start with "hr" or "sv"
$
$ ls -1 hr* sv*
hr12
hr16
hr20
hr22
sv00
sv01
sv02
sv23
$
$
$ ls -1 sv* hr* | perl -lne '$x{$_}++;
    END {
      $f = "FILENAME ";
      $h = "hr       ";
      $s = "sv       ";
      foreach $i (0..23) {
        $fmthr = sprintf("%02d",$i);
        $f .= " $fmthr";
        $h .= sprintf(" %2s", defined $x{"hr".$fmthr} ? "OK" : " X");
        $s .= sprintf(" %2s", defined $x{"sv".$fmthr} ? "OK" : " X");
      }
      print $f;
      print $h;
      print $s;
    }'
FILENAME  00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
hr         X  X  X  X  X  X  X  X  X  X  X  X OK  X  X  X OK  X  X  X OK  X OK  X
sv        OK OK OK  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X  X OK
$
$

tyler_durden
This User Gave Thanks to durden_tyler For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command to find files older than 1 hour

Hi, Out of a list of files in a directory, I want to find the files which were created/modified more than 1 hour ago. I am using HP -UNIX and it does not support the argument -mmin. Please advise. I am using # !/bin/sh (4 Replies)
Discussion started by: jhilmil
4 Replies

2. Shell Programming and Scripting

How to find the files created within one hour in Solaris?

Hi Gurus, I want to find the file created within one hour in solaris. I have tried below command, but it is no lucky. $find . -mtime -1/24, -name "abc*" above command give me the file name which created two hours ago find . -cmin -60, -name "abc*" above command I got error as... (4 Replies)
Discussion started by: ken6503
4 Replies

3. Shell Programming and Scripting

List last 1 hour files with out FIND command

Hi Friends, Can we have an alternate command to list last 1hour files with out FIND command? Thanks Suresh (6 Replies)
Discussion started by: suresh3566
6 Replies

4. UNIX for Dummies Questions & Answers

HP UNIX: How to find files which are older than one hour.

HP Unix Version: HP-UX B.11.31 U ia64 Question I look for script or command to find files which are older than one hour. Tried below; # set the file time to 1 hours ago touch -t 201307160700 ./touchfile find /app/grid/product/11.2.0.3/rdbms/audit -name '*.aud' -type f ! -newer... (4 Replies)
Discussion started by: Siva SQL
4 Replies

5. Shell Programming and Scripting

How to pick only the files which are generated in one hour?

Hello Masters, I need one help. I want to copy the files which are continuously generating on one server. But this would be on hourly basis. e.g. -rw-rw-r-- 1 akore akore 0 Feb 12 03:20 test1.log -rw-rw-r-- 1 akore akore 0 Feb 12 03:42 test2.log -rw-rw-r-- 1 akore akore 0 Feb 12 04:22... (2 Replies)
Discussion started by: akore83
2 Replies

6. Shell Programming and Scripting

How to convert 24 hour time to 12 hour timing?

Hi friends, I want to convert 24 hour timing to 12 hour please help me... my data file looks like this.. 13-Nov-2011 13:27:36 15.32044 72.68502 13-Nov-2011 12:08:31 15.31291 72.69807 16-Nov-2011 01:16:54 15.30844 72.74028 15-Nov-2011 20:09:25 15.35096 ... (13 Replies)
Discussion started by: nex_asp
13 Replies

7. Shell Programming and Scripting

Find files modified in last hour sunOS 5.10

trying to find a way to locate files modified in the last hour in a shell script, unfortunately the command 'find . -mmin -60' is not supported on SunOS 5.10 (works on OpenSolaris 5.11 :mad:) Does anyone know a method of doing this in shell script on 5.10? cheers (19 Replies)
Discussion started by: rich@ardz
19 Replies

8. Shell Programming and Scripting

Count files every hour

Hi, I have a directory which uploads files every minute.I want to check the number of files uploaded for every one hour. I want to run a cron every hour to chk this but iam hanged like how to write the script. Like the script should count for one hr ie from 00:00 to 01:00 hrs then next hr... (3 Replies)
Discussion started by: nessj
3 Replies

9. UNIX for Dummies Questions & Answers

To create alist of files created in the last 1 hour.

Hi, I need to create a script whcih ill run ever hour and will check all the files which are created in that hour for an error string. Need help in finding all the files which were created in the last 1 hour. Thanks in Advance. Asheesh (4 Replies)
Discussion started by: Asheesh
4 Replies

10. UNIX for Dummies Questions & Answers

display the files in a folder which are older than 1 hour

Hi, I have some files in a folder with different time stamps and I want to display the files which are older than 1 hour. i tried with find. need urgent help. (3 Replies)
Discussion started by: vgs
3 Replies
Login or Register to Ask a Question