exclude records with null fields


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting exclude records with null fields
# 1  
Old 03-01-2009
exclude records with null fields

Hi,
can I do something like this to add a condition of checking if the 4th field is number or space or blank also:

awk -F, '$4 /^[]*||[0-9]*/' MYFILE >> OTHERFILE

I also want the other part i.e. I need to exclude all lines whose 4th field is space or blank or number:

MYFILE
a,b,c,d,e
a,b,c,2,r
c,d,f,,g
t,y,u, ,i

The new file should contain only first line. I tried using the below but I also get 3rd line

awk -F, '$4 /^ [A-Z]*/' MYFILE >> OTHERFILE

I need OTHERFILE to have only first record.
# 2  
Old 03-01-2009
this will work .. but its not the efficient code Smilie
Code:
 
awk -F, '$4 !~ /^[0-9]/  && $4 !~ /^[ ]/ && $4!=""' filename

# 3  
Old 03-01-2009
What about:
Code:
awk -F, '$4 ~/^[a-zA-Z]/' file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Fields shifting in file, do to null values?

The below code runs and creates an output file with three sections. The first 2 sections are ok, but the third section doesn't seem to put a . in all the fields that are blank. I don't know if this is what causes the last two fields in the current output to shift to a newline, but I can not seem... (3 Replies)
Discussion started by: cmccabe
3 Replies

2. Shell Programming and Scripting

Select records and fields

Hi All I would like to modify a file like this: >antax gioq21 tris notes abcdefghij klmnopqrs >betax gion32 ter notes2 tuvzabcdef ahgskslsooin this: >tris abcdefghij klmnopqrs >ter tuvzabcdef ahgskslsoo So, I would like to remove the first two fields(and output field 3) in record... (4 Replies)
Discussion started by: giuliangiuseppe
4 Replies

3. Shell Programming and Scripting

UNIX scripting for finding duplicates and null records in pk columns

Hi, I have a requirement.for eg: i have a text file with pipe symbol as delimiter(|) with 4 columns a,b,c,d. Here a and b are primary key columns.. i want to process that file to find the duplicates and null values are in primary key columns(a,b) . I want to write the unique records in which... (5 Replies)
Discussion started by: praveenraj.1991
5 Replies

4. Shell Programming and Scripting

Aligning output with null fields in shell script

Hello Gurus ! I have what probably amounts to a few simply changes to fix; however for the life of me I cannot seem to get it ti work. I need to align the output of my script (I am writing to a logfile)... here's the lines in my code: if then echo "NODE: $node" >> $logfile... (6 Replies)
Discussion started by: gvolpini
6 Replies

5. Shell Programming and Scripting

Awk to Count Records with not null

Hi, I have a pipe seperated file I want to write a code to display count of lines that have 20th field not null. nawk -F"|" '{if ($20!="") print NR,$20}' xyz..txt This displays records with 20th field also null. I would like output as: (4 Replies)
Discussion started by: pinnacle
4 Replies

6. Shell Programming and Scripting

Find out if few fields in a file are null

Hi, I've a pipe delimited file where I want to find out a number of lines where 1st 2nd and last field are null using awk/sed. Is it possible? Thanks (5 Replies)
Discussion started by: rudoraj
5 Replies

7. UNIX for Advanced & Expert Users

exclude multiple records

Hi I need to exclude multiple records in file .Using grep -v ,can exclude that record Ex: If want to exclude 0012777201,0012777202 use grep two times .Is there any command to achive this through single command ?( cann't use grep multiple times if need to exclude multiple records in husge... (5 Replies)
Discussion started by: mohan705
5 Replies

8. Shell Programming and Scripting

Replace 3 fields with null in the file

Hi, I have a file with 104 columns delimited by comma. I have to replace fields 4,5 and 19 with null values and after replacing the columns in the file , the file should be still comma delimited. I am new to shell scripting, Experts please help me out. Thank you (1 Reply)
Discussion started by: vukkusila
1 Replies

9. Shell Programming and Scripting

finding null records in data file

I am having a "|" delimited flat file and I have to pick up all the records with the 2nd field having null value. Please suggest. (3 Replies)
Discussion started by: dsravan
3 Replies

10. Shell Programming and Scripting

Find null fields in file

Hi All, I have some csv files out of which i want to find records which have empty values in either the 14th or 16th fields. The following is a sample. $cut -d',' -f14,16 SPS* | head -5 VOIP_ORIG_INFO,VOIP_DEST_INFO sip:445600709315@sip.com,sip:999@sip.com... (2 Replies)
Discussion started by: rahulrathod
2 Replies
Login or Register to Ask a Question