Sponsored Content
Top Forums Shell Programming and Scripting How to check Null values in a file column by column if columns are Not NULLs Post 302116265 by Mandab on Wednesday 2nd of May 2007 04:25:50 PM
Old 05-02-2007
Excellent !! its working fine now.
But there is one small problem, If there is an error in field one and also field two then I should have only error to be printed as "102". but not both "102" and "104" to be printed, basing on the serial order of fields like field1, field2. Also can I use the error value in a variable so that I can use it for different purpose in my script(outside awk)?

Here is the script:
#!/bin/ksh

awk -F"," 'NR>=3 {
if (length($2)!= 8 || $2 ~ /[^0-9]/ || $2 ~ /^ *$/ ) {var1="102"}
if ( $4 ~ /^ *$/ ) {var1="104"}
{printf var1}
printf("\n")
}' $1


The output:


102
104
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Check for null values in a column

Hi All, I have a file with 10 columns and get the required data for nine columns properly except 8th. In 8th column i have both NULL and NON NULL values...i.e certain records have values for all the columns including 8th column and certain records have 8th column as NULL.My requisite is,without... (20 Replies)
Discussion started by: ganesh_248
20 Replies

2. Shell Programming and Scripting

Check for null values in columns

Hi , I have below data with fixed with of 52 bytes having three columns value data. 01930 MA GLOUCESTER 02033 02025 COHASSET 01960 MA ... (3 Replies)
Discussion started by: sonu_pal
3 Replies

3. Shell Programming and Scripting

Check to identify duplicate values at first column in csv file

Hello experts, I have a requirement where I have to implement two checks on a csv file: 1. Check to see if the value in first column is duplicate, if any value is duplicate script should exit. 2. Check to verify if the value at second column is between "yes" or "no", if it is anything else... (4 Replies)
Discussion started by: avikaljain
4 Replies

4. Shell Programming and Scripting

Check null values column

hi, I had a small question.I had a file from which i need to extract data. I have written the below script to check if the file exists and if it exists extract requierd columns from the file. IFILE=/home/home01/Report_1.csv OFILE=/home/home01/name.csv.out1 if #Checks if file exists... (1 Reply)
Discussion started by: Vivekit82
1 Replies

5. Shell Programming and Scripting

Script to check for null values in a column

Hi Guys, I am new to shell script.I need your help to write a shell script. I have a csv file which has 13 columns separated by , I have written below script to fetch required 5 columns. awk -F, '(NR==1){h3=$3;h4=$4;h8=$8;h9=$9;h13=$13;next}(NF>1) \ {print... (5 Replies)
Discussion started by: Vivekit82
5 Replies

6. Linux

To get all the columns in a CSV file based on unique values of particular column

cat sample.csv ID,Name,no 1,AAA,1 2,BBB,1 3,AAA,1 4,BBB,1 cut -d',' -f2 sample.csv | sort | uniq this gives only the 2nd column values Name AAA BBB How to I get all the columns of CSV along with this? (1 Reply)
Discussion started by: sanvel
1 Replies

7. UNIX for Dummies Questions & Answers

Check for not null column in a pipe delimited file

Hi, I have a requirement where I have to check whether the mandatory columns in a pipe delimited file is null and print error message. For eg, I have to check if the 3rd,5th,6th,7th and 8th column are null and print the message "<column name> is null". The data file will have aroung 100,000... (6 Replies)
Discussion started by: reshma15193
6 Replies

8. UNIX for Beginners Questions & Answers

Check for null values in a columns. I have dozen of CSV files in a directory.

Hi Folks, I'm trying to write a simple file sanity check script. I have a directory with dozen CSV files containing id,edname,firstname,lastname,suffix,email. I like to write a awk script to check if first field contain a number and is not empty. and fields number 3,4 & 6 are not empty and... (3 Replies)
Discussion started by: dc34684
3 Replies

9. UNIX for Beginners Questions & Answers

Copy columns from one file into another and get sum of column values and row count

I have a file abc.csv, from which I need column 24(PurchaseOrder_TotalCost) to get the sum_of_amounts with date and row count into another file say output.csv abc.csv- UTF-8,,,,,,,,,,,,,,,,,,,,,,,,, ... (6 Replies)
Discussion started by: Tahir_M
6 Replies
RAPOLICY(1)						      General Commands Manual						       RAPOLICY(1)

NAME
rapolicy - compare a argus(8) data file/stream against a Cisco Access Control List. COPYRIGHT
Copyright (c) 2000-2003 QoSient. All rights reserved. SYNOPSIS
rapolicy -r argus-file [ra options] DESCRIPTION
Rapolicy reads argus data from an argus-file list, and tests the argus data stream against a Cisco access control list configuration file, printing out records that represent activity that would violate the policy. Rapolicy can be used to indicate access control violations, as well as test new access control definitions prior to installing them in a router. OPTIONS
Rapolicy, like all ra based clients, supports a large number of options. Options that have specific meaning to rapolicy are: -f <Cisco ACL file> Print records that violate the policy. -D 0 (default) Print records that violate the policy. -D 1 Print records and the violated ruleset. -D 2 Print all records and the ruleset that matched. See ra(1) for a complete description of ra options. EXAMPLE INVOCATION
rapolicy -r argus.file CISCO ACL SYNTAX
There does not seem to be authoritative Cisco-ACL-Documentation, nor ACL syntax standardization. Because Cisco has been know to improve its ACL rules syntax, rapolicy is known to work with Cisco ACL router defintions up to July, 2002. A Cisco ACL configuration file consists of a collection of any number of ACL statements, each on a separte line. The syntax of an ACL statement is: ACL = "access-list" ID ACTION PROTOCOL SRC DST NOTIFICATION ID = Number ACTION = permit | deny PROTO = protocol name | protocol number SRC | DST = ADDRESS [PORTMATCH] ADDRESS = any | host HOSTADDR | HOSTADDR HOSTMASK HOSTADDR = ipV4 address HOSTMASK = matching-mask PORTMATCH = PORTOP PORTNUM | range PORTRANGE PORTOP = eq | lt | gt | neq | established PORTRANGE = PORTNUM PORTNUM PORTNUM = TCP or UDP port value (unsigned decimal from 0 to 65535) EXAMPLE CONFIGURATION
This example Cisco Access Control List configuration is provided as an example only. No effort has been made to verify that this example Access Control List enforces a useful access control policy of any kind. #allow www-traffic to webserver access-list 102 permit tcp any 193.174.13.99 0.0.0.0 eq 80 #allow ftp control connection to server access-list 102 permit tcp any 193.174.13.99 0.0.0.0 eq 21 #allow normal ftp access-list 102 permit tcp any 193.174.13.99 0.0.0.0 eq 20 #allow ftp passive conncetions in portrange 10000 to 10500 access-list 102 permit tcp any host 193.174.13.99 range 10000 10500 #dummy example access-list 102 permit tcp host 193.174.13.1 eq 12345 host 193.174.13.2 range 12345 23456 #deny the rest access-list 102 deny tcp any any #same thing in other words: access-list 102 deny tcp 0.0.0.0 255.255.255.255 0.0.0.0 255.255.255.255 AUTHORS
Carter Bullard (carter@qosient.com). Olaf Gellert (gellert@pca.dfn.de). SEE ALSO
ra(1), rarc(5), argus(8) 22 July 2002 RAPOLICY(1)
All times are GMT -4. The time now is 06:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy