How to get the Invalid records from a file using awk?
My Input file is fixed length record ends with . as end of the line and the character length is 4156
Example:
I need to check is there any control characters(like ^M,^Z)
The line will be splitted
the outptut should be
Is there any way to reduce the if conditions.. or the best way to achieve the ouput
Last edited by Scrutinizer; 04-30-2016 at 01:56 AM..
Reason: Corrected and moved code tags
I would use something more like:
Note that the opening single-quote for the awk program operand MUST be on the same line as awk.
Note that the 1st field's mutually exclusive failed tests are of the form err = " message" and all subsequent failed tests are of the form err = err "message".
Note that the leading <space> character in each of the error messages is crucial.
Note that if you're trying to test whether or not id is an alphanumeric string, you're using the wrong ERE. You should use something more like:
which will add an error message to err if there are any non-alphanumeric characters in id. Your current test will also allow colon, semicolon, less-than, equal-sign, greater-than, question-mark, and at-sign characters in id if you're using a codeset that is a superset of US-ASCII and is an ERE producing undefined results if you're using an EBCDIC codeset.
As always, if you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk or nawk.
I have two files and would need to filter out records based on certain criteria, these column are of variable lengths, but the lengths are uniform throughout all the records of the file. I have shown a sample of three records below. Line 1-9 is the item number "0227546_1" in the case of the first... (15 Replies)
hi.. I want to compare records present in 1 file with those in 3 other files and print those records of file 1 which are not present in any of the files. for eg -
file1 file2 file3 file4
1 1 5 7
2 2 6 9
3
4
5
6
7
8
9
... (3 Replies)
Hello,
I have attached one file named file.txt .
I have to create a file using the awk script with the records in which 38th position is P and not V .
ex
it should have
00501 HOLTSVILLE NYP00501
and it should not include
00501 I R S SERVICE CENTER ... (3 Replies)
HI,
I have a source file which has the below data.
Tableid,table.txt
sourceid,1,2,3,4,5,6
targetid,1,2,3,4,5,6
Tableid,table
sourceid,1,2,3,4,5,6
targetid,1,2,3,4,5,6
Tableid,table.txt
sourceid,1,2,3,4,5,6
targetid,1,2,3,4,5,6
Tableid,table
sourceid,1,2,3,4,5,6
targetid,1,2,3,4,5,6... (6 Replies)
Hello gurus,
I am new to "awk" and trying to break a large file having 4 million records into several output files each having half million but at the same time I want to keep the similar key records in the same output file, not to exist accross the files.
e.g. my data is like:
Row_Num,... (6 Replies)
Hi everyone.
I am a newbie to Linux stuff. I have this kind of problem which couldn't solve alone. I have a text file with records separated by empty lines like this:
ID: 20
Name: X
Age: 19
ID: 21
Name: Z
ID: 22
Email: xxx@yahoo.com
Name: Y
Age: 19
I want to grep records that... (4 Replies)
I want to filter records in one of my file using AWK command (or anyother command). I am using the below code
awk -F@ '$1=="0003"&&"$2==20100402" print {$0}' $INPUT > $OUTPUT
I want to pass the 0003 and 20100402 values through a variable. How can I do this?
Any help is much... (1 Reply)
Hello all,
Would appreciate if someone can help me out on the following requirement.
INPUT FILE:
--------------------------
TPS REPORT
abc def ghi
jkl mon pqr
stu vrs lll
END OF TPS REPORT
TPS REPORT
field1 field2 field3
field4 field5 field6 (8 Replies)
Hi,
I have a .txt file (uniqfields.txt) with 3 fields separated by " | " (pipe symbol). This file contains unique values with respect to all these 3 fields taken together. There are about 40,000 SORTED records (rows) in this file. Sample records are given below.
1TVAO|OVEPT|VO... (2 Replies)
I have a flat file and need to count no of records in the file less the header and the trailer record.
I would appreciate any and all asistance
Thanks
Hadi Lalani (2 Replies)