Record count checking for multiple files through for-loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Record count checking for multiple files through for-loop
# 8  
Old 06-02-2014
Hi Rudy,

Actually script given by you i executed and checked the result what it is doing checking the first file if data is there then getting executed exit command and coming out.Not checking for another file.

So I have prepared please review and correct me if anything wrong.

Thanks in advance..
# 9  
Old 06-02-2014
Sorry, I don't get the logics behind your request nor from your code snippet. Please explain in plain English what you want to achieve. Are you aware of the short circuit evaluation?
# 10  
Old 06-02-2014
Hi Rudy, I have executed the below script but it's checking the first file and if data found infile then it's getting executed exit 0 and coming out side without check the second file. a=/tjx/iisNAS/data/edw/fp/output/common/sample.txtb=/tjx/iisNAS/data/edw/fp/output/common/sample1.txtfor file in $a $bdo if [ 0 -eq $(wc -l <$file) ] then mailx ... exit 1 else mailx ... exit 0 fidoneCan you please verify and correct me if anything worng.

Thanks,
# 11  
Old 06-02-2014
Did you read (and understand) post 7 ?
Quote:
The reason for your complaint is called "shortcircuit evaluation" and is used in many languages: If the first operand in an and operation fails, the result is known and the second is not needed to be evaluated.
And, besides, why don't you use code tags as requested?

Last edited by RudiC; 06-02-2014 at 11:09 AM..
# 12  
Old 06-02-2014
Yes..Correct..

There may be some of the files which has zero records(Ex:First file has data..second file doesn't have data...) when it checks for first file it's gone through but second file doesn't have data as per my consern second file also has to be checked.
But it's coming out from for loop.

Ok..Anyhow thanks for your response...

Have a great day...
# 13  
Old 06-02-2014
Then you have to rephrase the logics. Check both files, keeping results in variables, then test the variables and proceed depending on test results.
# 14  
Old 06-02-2014
Ok..
I will check it Rudy..and prepare script..

Thanks in advance..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

CSV joining and checking multiple files

Hello, For our work we use several scripts to gather/combine data for use in our webshop. Untill now we did not had any problems but since a couple days we noticed some mismatches between imports. It happened that several barcodes where matched even though it was a complete other product. Of... (19 Replies)
Discussion started by: SDohmen
19 Replies

2. Shell Programming and Scripting

Checking File record equal to multiple of 70 or nearest number to multiple of 70

Hello, I have a file with below content - Example 3 6 69 139 210 345 395 418 490 492 I would like the result as - Multiple of 70 or nearest number in the file less than the multiple of 70 69 139 (5 Replies)
Discussion started by: Mannu2525
5 Replies

3. Shell Programming and Scripting

Shell script for field wise record count for different Files .csv files

Hi, Very good wishes to all! Please help to provide the shell script for generating the record counts in filed wise from the .csv file My question: Source file: Field1 Field2 Field3 abc 12f sLm 1234 hjd 12d Hyd 34 Chn My target file should generate the .csv file with the... (14 Replies)
Discussion started by: Kirands
14 Replies

4. Programming

awk to count occurrence of strings and loop for multiple columns

Hi all, If i would like to process a file input as below: col1 col2 col3 ...col100 1 A C E A ... 3 D E G A 5 T T A A 6 D C A G how can i perform a for loop to count the occurences of letters in each column? (just like uniq -c ) in every column. on top of that, i would also like... (8 Replies)
Discussion started by: iling14
8 Replies

5. Shell Programming and Scripting

count of record in files

Hi all, I have written a scripts which count number of lines in all the files in a directory and write in a text file. I don't know how to format it while writing. OS suns solaris 10 my scripts is as below for i in /ersdg3/ERS/ERS_INPUT_LOGS/RIO/LOGS/RIO_02-Aug-2012/ *.LOG do echo... (11 Replies)
Discussion started by: guddu_12
11 Replies

6. Shell Programming and Scripting

Checking the existance of multiple files

I am trying to execute the following command to check the existance of a file (which has a date timestamp on it). If there are more than one file, then also it should give me 'success' result. if then <do some work> else <no files> fi Since there are more than one... (18 Replies)
Discussion started by: vivek_damodaran
18 Replies

7. Shell Programming and Scripting

Comparison of record count of two files

Hi, I have one text file and zip file in UNIX directory.The Zip file contains another text file. For Ex: Text File Name = Req_file.txt Zip file Name= Response_file.txt_04072009_121548.gz Zip file contains one text file that name is Response_file.txt I want to compare the record... (1 Reply)
Discussion started by: praka
1 Replies

8. Shell Programming and Scripting

bash if loop for checking multiple parameters

Hello, I've got next problem: I want to examine at the beginning of a script in an if loop that: 1. Is there 4 parameters given 2. If first state is true then: is there switches -e and -d? 3. At the end, how can i indentify them as variebles regardlees to its order. I was thinking like... (2 Replies)
Discussion started by: szittyafergeteg
2 Replies

9. Shell Programming and Scripting

checking count of files and exiting

Hi All Please see the script below for file in ${filelist }; do if ]; then if ]; then print " $(date) STEP 6 ------- Copying $file to $destpath" fi if ! cp $ftppath/$file $destpath 2> /dev/null; then writeToLog "ERROR: ${0##*/} - $upartition Could not copy file $file" if ]; then... (1 Reply)
Discussion started by: king007
1 Replies

10. Shell Programming and Scripting

replaying a record count with another record count

i use unix command to take the record count for a file1 awk 'END{print NR}' filename i already have a file2 which conatin the count like ... .. rec_cnt=100 .. .. I want to replace the record in the file2 using the record i take from file1. suggest me some simple ways of doing it... (2 Replies)
Discussion started by: er_zeeshan05
2 Replies
Login or Register to Ask a Question