validation required in unix


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers validation required in unix
# 1  
Old 09-25-2008
validation required in unix

is there any way to check null data against some of the column in file

My file have such structure

Code:
1,,4,SUMISHO  ,SMG110880 ,1,12,SUMISHO CAPITAL MANAGEMENT (SINGAPORE) PTE LTD                        ,ACCT01,20080531,2008,5,30,20080630,1,1,TXGRP ,CGST  ,1,74,5.18,74,0,5.18
2,,4,20,12,12,0.84,500020-999,,,,,,,,,,,,,,,,
2,,4,40,8,8,0.56,500030-999,,,,,,,,,,,,,,,,
2,,4,60,20,20,1.4,500080-PAC,,,,,,,,,,,,,,,,
2,,4,80,12,12,0.84,500020-RPA,,,,,,,,,,,,,,,,
2,,4,100,22,22,1.54,500030-RPA,,,,,,,,,,,,,,,,
3,,4,1,,,,,,,,,,,,,,,,,,,,

I want to check some of column are null or not.

How to do that ,any sample code would be highly apprecaited.
# 2  
Old 09-25-2008
Code:
 
var=0
while read line
do
var=`expr $var + 1`
echo "null colums in line $var are"
echo "$line"|awk 'BEGIN{RS=","}{if ( $0 == "" ){print "column no="NR" is null"}}'
done < filename

but it give the line no.. and the null column no..

Last edited by vidyadhar85; 09-25-2008 at 04:36 AM..
# 3  
Old 09-25-2008
awk

thanks vidhya

can we do validation for a line or for some column in line

Can i pass the file name and how it possible to display some flag by mean of flag.


HTML Code:
1,,4,SUMISHO  ,[COLOR="Red"]SMG110880 [/COLOR],1,12,SUMISHO CAPITAL MANAGEMENT (SINGAPORE) PTE LTD                        ,ACCT01,20080531,2008,5,30,20080630,1,1,TXGRP ,CGST  ,1,74,5.18,74,0,5.18
2,,4,20,12,12,0.[COLOR="red"]84[/COLOR],500020-999,,,,,,,,,,,,,,,,
2,,4,40,8,8,0.[COLOR="red"]56[/COLOR],500030-999,,,,,,,,,,,,,,,,
2,,4,60,20,20,1.4,500080-PAC,,,,,,,,,,,,,,,,
2,,4,80,12,12,0.84,500020-RPA,,,,,,,,,,,,,,,,
2,,4,100,22,22,1.54,[COLOR="red"]500030[/COLOR]-RPA,,,,,,,,,,,,,,,,
3,,4,1,,,,,,,,,,,,,,,,,,,,
In above case if red font words have NULL can it possible to display same record in report and last line should have message.
came to know AWK can do
any insight
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PAN card validation using UNIX

Please help me to validate PAN card using unix ---------- Post updated at 03:06 AM ---------- Previous update was at 02:21 AM ---------- 1) The first three letters are sequence of alphabets from AAA to zzz 2) The fourth character informs about the type of holder of the Card. Each assesse... (1 Reply)
Discussion started by: suryanarayana
1 Replies

2. UNIX for Dummies Questions & Answers

Unix date validation

Dears, I am working on a batch that processes file with name containing date prefix eg., 20101222_file.dat. The logic is to process files in order. Eg., 20101225 must be processed only after 20101222. Ok first glance it looked simple, it use a variable to check this date value as number and... (2 Replies)
Discussion started by: naraink
2 Replies

3. Shell Programming and Scripting

Date Validation in unix

I have a script which is take date as parameter sh abc.sh <2010-02-01> #!/sh/bin my_date=$1 #Here i want to two diffrent dates ## 3 Days before ##date14query=$mydate - 4 (it will be 2010-01-28) ##date24query=$mydate +4 (it will be 2010-01-05) #Please Help (3 Replies)
Discussion started by: pritish.sas
3 Replies

4. Shell Programming and Scripting

Getting required fields from a test file in required fromat in unix

My data is something like shown below. date1 date2 aaa bbbb ccccc date3 date4 dddd eeeeeee ffffffffff ggggg hh I want the output like this date1date2 aaa eeeeee I serached in the forum but didn't find the exact matching solution. Please help. (7 Replies)
Discussion started by: rdhanek
7 Replies

5. Shell Programming and Scripting

Unix File Validation! Help

Hi All, I got a file with 3 fields delimited by hyphen "-". I have to validate & cleanse the data before i begine the processing Requirements 1. No record should contain more than 2 delimiters 2. No record should even contain less than 2 delimiters 3. Any records that matches rule 1 &... (8 Replies)
Discussion started by: minnuverma
8 Replies

6. UNIX for Advanced & Expert Users

Unix File Validation! Help

Hi All, I got a file with 3 fields delimited by hyphen "-". I have to validate & cleanse the data before i begine the processing Requirements 1. No record should contain more than 2 delimiters 2. No record should even contain less than 2 delimiters 3. Any records that matches rule 1 &... (3 Replies)
Discussion started by: minnuverma
3 Replies

7. UNIX for Dummies Questions & Answers

Unix File Validation! Help

Hi All, I got a file with 3 fields delimited by hyphen "-". I have to validate & cleanse the data before i begine the processing Requirements 1. No record should contain more than 2 delimiters 2. No record should even contain less than 2 delimiters 3. Any records that matches rule 1 &... (1 Reply)
Discussion started by: minnuverma
1 Replies

8. Shell Programming and Scripting

UNIX script Validation

Hi, I have a UNIX script which has two parts: 1. It connects to a database and refreshes a materialized view 2. It then connects to another database and inserts refresh statistics to a table The script works, but I'm not too good at UNIX validation. Currently, if the first part of the job... (1 Reply)
Discussion started by: matchey
1 Replies

9. UNIX for Dummies Questions & Answers

How Can I Do Time Validation in UNIX

I am very new to scripting in UNIX and in need of help. I am creating a program that will check a file that has a target time in the form of HH:MM:SS before another program can begin executing. The file with the target time will only have that target time in it and nothing else. Is there any... (4 Replies)
Discussion started by: mosammey
4 Replies

10. Shell Programming and Scripting

Time Validation in UNIX?

I am very new to scripting in UNIX and in need of help. I am creating a program that will check a file that has a target time in the form of HH:MM:SS before another program can begin executing. The file with the target time will only have that target time in it and nothing else. Is there any way... (1 Reply)
Discussion started by: mosammey
1 Replies
Login or Register to Ask a Question