List files only when a certain number of files match


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting List files only when a certain number of files match
# 8  
Old 07-21-2011
Yes zaxxon, we receive 12 file per hour if we receive for exmaple 11 at 05 hour so there is one file missing, i have to list all received files at 05h to find which of them are missing. I hope now you understand me well. Thanks


thank you maskofzorro, Actually i'm new in shell scripting and i need a little time to get more about the SED and GENSUB commands to understand your scripts, but it's working on the example thanks Smilie
# 9  
Old 07-21-2011
There is missing the hours 03 in the output. A tad shorter:
Code:
awk '{a=substr($1,12,2); if(a<=10) {_[a]++}} END{printf("%-10s%-10s\n", "Count", "Hour"); for(e in _){printf("%-10s%-10s\n"),  _[e],e}}' infile
Count     Hour
1         10
3         01
3         02
6         03

# 10  
Old 07-23-2011
You can try this

Code:
a=12
b=` date +%Y%m%d`
c=` ls -ltr | grep 'CCD_'$b | tr -s ' ' | cut -d ' ' -f8 | cut -c1-2 | wc -l`
if [$c -eq $a ]
then
echo 'The files are good'
else
echo 'The files are not good'
exit
fi

but you have to run this script in every hour,and this will give you the CCD file counts for that hour,you can schedule it by using crontab.

Thanks,
Pragyan

Last edited by radoulov; 07-23-2011 at 12:07 PM.. Reason: Code tags!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Count the number of files to delete doesnt match

Good evening, need your help please Need to delete certain files before octobre 1 2016, so need to know how many files im going to delete, for instance ls -lrt file_20160*.lis!wc -l but using grep -c to another file called bplist which contains the list of all files backed up doesn match... (7 Replies)
Discussion started by: alexcol
7 Replies

2. Shell Programming and Scripting

List files with number to select based on number

Hi experts, I am using KSH and I am need to display file with number in front of file names and user can select it by entering the number. I am trying to use following command to display list with numbers. but I do not know how to capture number and identify what file it is to be used for... (5 Replies)
Discussion started by: mysocks
5 Replies

3. Shell Programming and Scripting

Rename files to match file list pattern

Hi All, I have 100 folders with the first delimiter has a unique name i.e (123_hello and 575_hello) and each folder have atlist 1000 plus files with naming convention i.e (575_hello_1.iso ... 575_hello_1000.iso). 575_hello/575_hello_1.iso 575_hello/575_hello_2.iso 575_hello/575_hello_3.iso... (8 Replies)
Discussion started by: lxdorney
8 Replies

4. Shell Programming and Scripting

Finding log files that match number pattern

I have logs files which are generated each day depending on how many processes are running. Some days it could spin up 30 processes. Other days it could spin up 50. The log files all have the same pattern with the number being the different factor. e.g. LOG_FILE_1.log LOG_FILE_2.log etc etc ... (2 Replies)
Discussion started by: atelford
2 Replies

5. Shell Programming and Scripting

Match number from 2 input files

I have 2 input files; file1: 1 1000 2000 x1 1 5000 7000 x5 1 8000 10000 x8 file2: 1 1000 x1 z1 2 1001 x2 z2 1 1999 x3 z3 2 2000 x4 z4 1 2001 x5 z5 1 2002 x6 z6 1 6100 x7 z7 1 6200 x8 z8 1 7500 x9 z9 2 8500 x10 z10 I want to get the output look like this (1 Reply)
Discussion started by: akenaza
1 Replies

6. Shell Programming and Scripting

grep - match files containing minimum number of pattern matches

I want to search a bunch of files and list only those containing a minimum number of pattern matches. So if I want to identify files containing 3 (or more) instances of the pattern "said:" and I have file1 that contains the lines: He said: She said: and file2 that contains the lines: He... (3 Replies)
Discussion started by: stumpyuk
3 Replies

7. UNIX for Dummies Questions & Answers

How to list number of files through Crontab?

Hello All, I am trying to put this line in Crontab (Linux box- x86_64), but the command is not running. Can you please help me out? My requirement is- To find out the number of .csv files older than 1 day in directory /stage/landing. There are 2 other subdirectories under this directory... (6 Replies)
Discussion started by: NARESH1302
6 Replies

8. UNIX for Dummies Questions & Answers

Comparing two files and count number of lines that match

Hello all, I always found help for my problems using the search option, but this time my request is too specific. I have two files that I want to compare. File1 is the index and File2 contains the data: File1: chr1 protein_coding exon 500 600 . + . gene_id "20532";... (0 Replies)
Discussion started by: DerSeb
0 Replies

9. UNIX for Dummies Questions & Answers

List files that do not match the search pattern

I need to list the files that do not match the search pattern: Example: cat file1 This is how it should work cat file2 This is why I like Unix grep -option? Unix * (or some other command) returns file1 (7 Replies)
Discussion started by: olapxpert
7 Replies

10. IP Networking

List files that do not match the search pattern

I need to list the files that do not match the search pattern: Example: cat file1 This is how it should work cat file2 This is why I like Unix grep -option? Unix * (or some other command) returns file1 (1 Reply)
Discussion started by: olapxpert
1 Replies
Login or Register to Ask a Question