Sponsored Content
Top Forums Shell Programming and Scripting Finding only one error in a row Post 302822853 by srivalli on Tuesday 18th of June 2013 09:44:54 AM
Old 06-18-2013
Finding only one error in a row

I am using below code to validate whether datatype,length and date format is correct as defined in file_layout.
Below code is able to find only one error in a row,if there is more than one error in a same row then code is not able to highlight second error.
How to customize the below code to find all errors in a particular row.
Code:
awk -FÇ  '
NR==1{next}
{f="ok"}
$1!~/^[a-zA-Z0-9.%&@: -]{0,12}$/{f="ServicerID-error"} 
$2!~/^[0-9]{0,10}$/{f="LetterHistoryID-error"} 
$3!~/^[a-zA-Z0-9.%&@: -]{0,10}$/{f="Loan_No-error"} 
$4!~/^[a-zA-Z0-9.%&@: -]{0,15}$/{f="PRIOR_LOAN-error"} 
$5!~/^[a-zA-Z0-9.%&@: -]{0,15}$/{f="InvLoanNo-error"} 
$6!~/^[0-9]{0,4}-[0-9]{0,2}-[0-9]{0,2} [0-9]{0,2}:[0-9]{0,2}:[0-9]{0,2}$|^[" "]{0,38}$/{f="Letter_Date-error"} 
$7!~/^[a-zA-Z0-9.%&@: -]{0,10}$/{f="Code-error"} 
$8!~/^[a-zA-Z0-9.%&@: -]{0,50}$/{f="Letter_Type-error"} 
$9!~/^[0-9]{0,4}-[0-9]{0,2}-[0-9]{0,2} [0-9]{0,2}:[0-9]{0,2}:[0-9]{0,2}$|^[" "]{0,38}$/{f="DataAsOfDate-error"} 
{print f,$0}
' src_OCW_d_Letter_Tran_File_20130612_001.dat


Last edited by Scott; 07-01-2013 at 07:36 AM.. Reason: Removed formatting; fixed code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Changing the column for a row in a text file and adding another row

Hi, I want to write a shell script which increments a particular column in a row from a text file and then adds another row below the current row with the incremented value . For Eg . if the input file has a row : abc xyz lmn 89 lm nk o p I would like the script to create something like... (9 Replies)
Discussion started by: aYankeeFan
9 Replies

2. UNIX for Advanced & Expert Users

Finding last row

Using Linux and Bash, I have a script that outputs filenames with complete path, like this:I would like the following output:And I would like to get the filenames only. Tricky part is that I cannot predict how many levels deep the filename is located, so I cannot use standard Bash-kungfu to solve... (7 Replies)
Discussion started by: indo1144
7 Replies

3. Shell Programming and Scripting

Finding Minimum value per Row range of data

Here is an example of a file I am working with: C 4704 CB 1318 ASP 115 BGRF 1 weak 0.0% 4.33 C 4720 OD 1322 ASP 115 BGRF 1 weak 0.0% 3.71 O 4723 OD 1322 ASP 115 BGRF 1 weak 0.0% 3.48 O 4723 CG 1321 ASP 115 BGRF 1 weak 0.0% 4.34... (3 Replies)
Discussion started by: userix
3 Replies

4. UNIX for Dummies Questions & Answers

Shell Script: Traverse Database Table Row by Row

Hello Everyone, My issue is that I want to traverse a database table row by row and do some action on the value retrieved in each row. I have gone through a lot of shell script questions/posts. I could find row by row traversal of a file but not a database table. Please help. Thanks &... (5 Replies)
Discussion started by: ahsan.asghar
5 Replies

5. UNIX for Dummies Questions & Answers

Finding files with one row then moving them

Hi guys can you please help me with a script to find files with one row the move the file to another directory the files are in /optima/prd/optdir/ZTE_BSS/Combiner/ZTE_2G/out/BSC_PS_Basic_Meas and I want to move them to /optima/prd/optdir/ZTE_BSS/Loader/error/ZTE_2G/BSC_PS_Basic_Meas ... (5 Replies)
Discussion started by: Dj Moi
5 Replies

6. UNIX for Dummies Questions & Answers

Finding row number along with length of row

I have a fixed length file and I want to find out row number along with row length. I have a program that give me the line length if it satisfy the condition; but i would like to add row number as well? How do I do that? while IFS= read -r line; do if ; then echo ${line} echo... (8 Replies)
Discussion started by: princetd001
8 Replies

7. Shell Programming and Scripting

Add Row from First Row (Split Row)

HI Guys, I have Below Input :- RepigA_hteis522 ReptCfiEtrBsCll_aofe MSL04_MSL2_A25_1A 0 9 MSL04_MSL2_A25_1B 0 9 MSL04_MSL2_A25_1C 0 9 RepigA ReptCfiEtrBsCll hteis522 aofe MSL04_MSL2_A25_1A 0 9 MSL04_MSL2_A25_1B 0 9 MSL04_MSL2_A25_1C 0 9 Split Data in two first row... (2 Replies)
Discussion started by: pareshkp
2 Replies

8. UNIX for Beginners Questions & Answers

Keep only the closet match of timestamped row (include headers) from file1 to precede file2 row/s

My original files are like this below and I distinguish them from the AP_ID (file1 has 572 and file2 has 544). Also, the header on file1 has “G_” pre-pended. NOTE: these are only snippets of very large files and much of the data is not present here. Original File 1: ... (36 Replies)
Discussion started by: aachave1
36 Replies

9. Shell Programming and Scripting

Splitting single row into multiple rows based on for every 10 digits of last field of the row

Hi ALL, We have requirement in a file, i have multiple rows. Example below: Input file rows 01,1,102319,0,0,70,26,U,1,331,000000113200000011920000001212 01,1,102319,0,1,80,20,U,1,241,00000059420000006021 I need my output file should be as mentioned below. Last field should split for... (4 Replies)
Discussion started by: kotra
4 Replies

10. UNIX for Beginners Questions & Answers

Keep only the closet match of timestamped row (include headers) from file1 to precede file2 row/s

This is a question that is related to one I had last August when I was trying to sort/merge two files by millsecond time column (in this case column 6). The script (below) that helped me last august by RudiC solved the puzzle of sorting/merging two files by time, except it gets lost when the... (0 Replies)
Discussion started by: aachave1
0 Replies
ERR_print_errors(3)						      OpenSSL						       ERR_print_errors(3)

NAME
ERR_print_errors, ERR_print_errors_fp - print error messages SYNOPSIS
#include <openssl/err.h> void ERR_print_errors(BIO *bp); void ERR_print_errors_fp(FILE *fp); DESCRIPTION
ERR_print_errors() is a convenience function that prints the error strings for all errors that OpenSSL has recorded to bp, thus emptying the error queue. ERR_print_errors_fp() is the same, except that the output goes to a FILE. The error strings will have the following format: [pid]:error:[error code]:[library name]:[function name]:[reason string]:[file name]:[line]:[optional text message] error code is an 8 digit hexadecimal number. library name, function name and reason string are ASCII text, as is optional text message if one was set for the respective error code. If there is no text string registered for the given error code, the error string will contain the numeric code. RETURN VALUES
ERR_print_errors() and ERR_print_errors_fp() return no values. SEE ALSO
err(3), ERR_error_string(3), ERR_get_error(3), ERR_load_crypto_strings(3), SSL_load_error_strings(3) HISTORY
ERR_print_errors() and ERR_print_errors_fp() are available in all versions of SSLeay and OpenSSL. 50 2013-03-05 ERR_print_errors(3)
All times are GMT -4. The time now is 12:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy