If field 12 = NO then


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting If field 12 = NO then
# 1  
Old 10-08-2014
If field 12 = NO then

Hallo Team,

I have thousands of .csv files with the following naming convention BW*2014*.csv. I will attach a sample for one file. This is what i would like to do:

1. If field 12 is equal to No then move the file to a file called No_Answer.csv and delete it from BW*2014*.csv.

Here is a sample below:

Code:
-bash-3.2$ grep "716780068810201413130@192.168.155.2" BW*2014*
BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20141008130500-2-AC162DB137C8-168113-000.csv_rejected_6090130-20141008132313.log:0028163240AC162DB137C820141008110109.0470+020000,TURRITO NETWORKS,Normal,+27873537835,,Terminating,+27315384895,Public,0873537835,20141008110109.047,0+020000,No,,20141008110113.105,003,VoIP,,,,,,,local,10.0.4.206,716780068810201413130@192.168.155.2,PCMA/8000,10.0.4.206,BW130109049081014-592210965@196.35.130.5,,,,BUSINESS-GENETICS,,,,,,,,,,n,,,4295995761:16,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0873537835@isvoip.net,0315384895,Public,,,,,,,,,,,,BUSINESS-GENETICS/BT-BUSINESS-GENETICS-2-PBX,,,,,,No,,,,,,,,,,,,,,,,2.918,,,,,,,,,,,,,,,,,,,,,,,,,Unreachable,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Network,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,No,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0873537835@10.0.4.206,Primary Device,2.918,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,|Y,Unknown scenario:BST

# 2  
Old 10-08-2014
How many lines in each of these files? If each of these files have more than one line, are all the FIELD 12's the same? I don't see your sample file that you say is attached.
This User Gave Thanks to blackrageous For This Post:
# 3  
Old 10-08-2014
How many lines from the files are in the single line above? grep returns the file name : then the line in the file.
Code:
# example:
filename:[line with the matching item]

I see several colons on the line.
This User Gave Thanks to jim mcnamara For This Post:
# 4  
Old 10-08-2014
The lines in each file differ. One file might have a hundred line and one file might have 800 lines.

Code:
-bash-3.2$ ll BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log
-rw-r--r-- 1 mind mind 1328833 Oct  8 15:08 BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log
-bash-3.2$ cat BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log|wc -l
785
-bash-3.2$ cat BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log|head
BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141008011202.log:BW-CDR-20141007171500-2-AC162DB137C8-167875-000.csv_rejected_6086430-20141007214413.log:0026069654AC162DB137C820141007151253.8060+020000,DNA-ECONOMICS,Normal,+27873570612,,Originating,+27873570612,Public,0873570630,20141007151253.806,0+020000,Yes,20141007151253.860,20141007151303.793,016,VoIP,,873570630,private,,,,local,Group,,G729/8000,10.0.4.111,8f64e29d-7bb1090fdc667396d7800800234f5d89@10.101.11.4,,,,DNA-ECONOMICS-HATFIELD,HATFIELD (DNA-ECONOMICS-HATFIELD),,,,,,,,,n,,,4287503959:0,4287503963:0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0873570612@isvoip.net,Voice Portal Voice Portal,Public,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9.933,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Group,,,,,,,,,,,,,,,,+27873570612,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0873570612@isvoip.net,Primary Device,9.933,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Panasonic_KX-TGP500B01/22.58 (0800234f5d89),,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,|Y,ACCOUNT NOT FOUND (9)
BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141008011202.log:BW-CDR-20141007171000-2-AC162DB137C8-167874-000.csv_rejected_6086402-20141007214413.log:0026058897AC162DB137C820141007150812.3590+020000,DNA-ECONOMICS,Normal,+27873570612,,Originating,+27873570612,Public,0873570625,20141007150812.359,0+020000,Yes,20141007150826.524,20141007150905.082,016,VoIP,,0625,private,,,,local,Group,,G729/8000,10.0.4.111,4b9eaa60-62b0090fd9cc3c29d6800800234f5d89@10.101.11.4,,,,DNA-ECONOMICS-HATFIELD,HATFIELD (DNA-ECONOMICS-HATFIELD),,,,,,,,,n,,,4287462357:0,4287462361:0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0873570612@isvoip.net,Stephen Chisadza,Public,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,38.557,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Group,,,,,,,,,,,,,,,,+27873570612,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0873570612@isvoip.net,Primary Device,38.557,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Panasonic_KX-TGP500B01/22.58 (0800234f5d89),,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,|Y,ACCOUNT NOT FOUND (9)
BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20141007213500-2-AC162DB137C8-167927-000.csv_rejected_6086806-20141007222844.log:0026319839AC162DB137C820141007193334.2150+020000,CHEM-SPEC,Normal,+27873549997,,Originating,+27873549997,Anonymous,0824312318,20141007193334.215,0+020000,Yes,20141007193344.286,20141007193434.451,016,VoIP,,0824312318,national,mobi,0824312318,,remote,10.0.110.13:5060,BW213334219071014353507683@196.35.130.5,G729/8000,10.0.12.135,7254F1E1-4D8F11E4-B90EF6CA-EBABF7F8@197.96.243.105,,,,CHEM-SPEC-DBN,,,,,,,,,,y,public,,4288650287:0,,Ordinary,,,,,,,,,,,,cigZIJCPMaxHAAT2BGXMBURCPQQ-,10.31.53.11,cth.vodacom.co.za,cth.vodacom.co.za,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,873549997@isvoip.net,,,,,,,,,,,,,,CHEM-SPEC-DBN/BT-CHEM-SPEC,,,,,,,,,,,,,,,,,,,,,,59.809,,,,,,,,,,,,,,,,,,,,,,,,,Normal,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Network,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0873549997@10.0.12.135:5060,Primary Device,59.809,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Cisco-SIPGateway/IOS-15.3.3.M2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,|Y,ACCOUNT NOT FOUND (9)
BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20141008063500-2-AC162DB137C8-168035-000.csv_rejected_6089351-20141008065244.log:0026351546AC162DB137C820141008043140.6410+020000,CHEM-SPEC,Normal,+27873549997,,Originating,+27873549997,Anonymous,0313143300,20141008043140.641,0+020000,No,,20141008043145.012,003,VoIP,,0313143300,interlat,to,0313143300,,remote,10.0.108.11:5060,BW063140644081014-1609355389@196.35.130.5,G729/8000,10.0.12.135,9E8F6D59-4DDA11E4-B932F6CA-EBABF7F8@197.96.243.105,,,,CHEM-SPEC-DBN,,,,,,,,,,n,public,,4289631739:0,,Ordinary,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,873549997@isvoip.net,,,,,,,,,,,,,,CHEM-SPEC-DBN/BT-CHEM-SPEC,,,,,,,,,,,,,,,,,,,,,,10.268,,,,,,,,,,,,,,,,,,,,,,,,,Normal,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Network,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0873549997@10.0.12.135:5060,Primary Device,0.000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Cisco-SIPGateway/IOS-15.3.3.M2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,|Y,ACCOUNT NOT FOUND (9)
BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20141008063500-2-AC162DB137C8-168035-000.csv_rejected_6089351-20141008065244.log:0026352433AC162DB137C820141008043408.6810+020000,CHEM-SPEC,Normal,+27873549997,,Originating,+27873549997,Anonymous,0313143300,20141008043408.681,0+020000,No,,20141008043413.857,003,VoIP,,0313143300,interlat,to,0313143300,,remote,10.0.108.11:5060,BW063408684081014-128356948@196.35.130.5,G729/8000,10.0.12.135,F6CC8981-4DDA11E4-B94AF6CA-EBABF7F8@197.96.243.105,,,,CHEM-SPEC-DBN,,,,,,,,,,n,public,,4289638803:0,,Ordinary,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,873549997@isvoip.net,,,,,,,,,,,,,,CHEM-SPEC-DBN/BT-CHEM-SPEC,,,,,,,,,,,,,,,,,,,,,,7.016,,,,,,,,,,,,,,,,,,,,,,,,,Normal,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Network,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0873549997@10.0.12.135:5060,Primary Device,0.000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Cisco-SIPGateway/IOS-15.3.3.M2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,|Y,ACCOUNT NOT FOUND (9)
BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20141008063500-2-AC162DB137C8-168035-000.csv_rejected_6089351-20141008065244.log:0026351702AC162DB137C820141008043205.6200+020000,CHEM-SPEC,Normal,+27873549997,,Originating,+27873549997,Anonymous,0313143300,20141008043205.620,0+020000,No,,20141008043209.515,003,VoIP,,0313143300,interlat,to,0313143300,,remote,10.0.108.11:5060,BW063205624081014106587261@196.35.130.5,G729/8000,10.0.12.135,AD731311-4DDA11E4-B938F6CA-EBABF7F8@197.96.243.105,,,,CHEM-SPEC-DBN,,,,,,,,,,n,public,,4289632873:0,,Ordinary,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,873549997@isvoip.net,,,,,,,,,,,,,,CHEM-SPEC-DBN/BT-CHEM-SPEC,,,,,,,,,,,,,,,,,,,,,,9.880,,,,,,,,,,,,,,,,,,,,,,,,,Normal,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Network,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0873549997@10.0.12.135:5060,Primary Device,0.000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Cisco-SIPGateway/IOS-15.3.3.M2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,|Y,ACCOUNT NOT FOUND (9)
BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20141008063500-2-AC162DB137C8-168035-000.csv_rejected_6089351-20141008065244.log:0026352538AC162DB137C820141008043434.7010+020000,CHEM-SPEC,Normal,+27873549997,,Originating,+27873549997,Anonymous,03334267556073,20141008043434.701,0+020000,No,,20141008043438.079,001,VoIP,,03334267556073,,,,,local,unconfirmed,,G729/8000,10.0.12.135,64EDFE1-4DDB11E4-B950F6CA-EBABF7F8@197.96.243.105,,,,CHEM-SPEC-DBN,,,,,,,,,,n,,,4289640077:0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,873549997@isvoip.net,,,,,,,,,,,,,,CHEM-SPEC-DBN/BT-CHEM-SPEC,,,,,,,,,,,,,,,,,,,,,,3.280,,,,,,,,,,,,,,,,,,,,,,,,,Normal,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Network,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0873549997@10.0.12.135:5060,Primary Device,3.280,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Cisco-SIPGateway/IOS-15.3.3.M2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,|Y,ACCOUNT NOT FOUND (9)
BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20141008063500-2-AC162DB137C8-168035-000.csv_rejected_6089351-20141008065244.log:0026352645AC162DB137C820141008043445.7010+020000,CHEM-SPEC,Normal,+27873549997,,Originating,+27873549997,Anonymous,0313143300,20141008043445.701,0+020000,No,,20141008043450.958,003,VoIP,,0313143300,interlat,to,0313143300,,remote,10.0.108.11:5060,BW063445720081014410010582@196.35.130.5,G729/8000,10.0.12.135,CDD5761-4DDB11E4-B956F6CA-EBABF7F8@197.96.243.105,,,,CHEM-SPEC-DBN,,,,,,,,,,n,public,,4289640549:0,,Ordinary,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,873549997@isvoip.net,,,,,,,,,,,,,,CHEM-SPEC-DBN/BT-CHEM-SPEC,,,,,,,,,,,,,,,,,,,,,,4.014,,,,,,,,,,,,,,,,,,,,,,,,,Normal,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Network,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0873549997@10.0.12.135:5060,Primary Device,0.000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Cisco-SIPGateway/IOS-15.3.3.M2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,|Y,ACCOUNT NOT FOUND (9)
BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20141008063500-2-AC162DB137C8-168035-000.csv_rejected_6089351-20141008065244.log:0026352178AC162DB137C820141008043327.6610+020000,CHEM-SPEC,Normal,+27873549997,,Originating,+27873549997,Anonymous,0313143300,20141008043327.661,0+020000,No,,20141008043332.711,003,VoIP,,0313143300,interlat,to,0313143300,,remote,10.0.108.11:5060,BW0633276630810141774775090@196.35.130.5,G729/8000,10.0.12.135,DE596239-4DDA11E4-B944F6CA-EBABF7F8@197.96.243.105,,,,CHEM-SPEC-DBN,,,,,,,,,,n,public,,4289636677:0,,Ordinary,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,873549997@isvoip.net,,,,,,,,,,,,,,CHEM-SPEC-DBN/BT-CHEM-SPEC,,,,,,,,,,,,,,,,,,,,,,6.368,,,,,,,,,,,,,,,,,,,,,,,,,Normal,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Network,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0873549997@10.0.12.135:5060,Primary Device,0.000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Cisco-SIPGateway/IOS-15.3.3.M2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,|Y,ACCOUNT NOT FOUND (9)
BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20140102072500-2-AC162DB137C8-087691-000.csv_rejected_6087016-20141007220203.log:BW-CDR-20141008063500-2-AC162DB137C8-168035-000.csv_rejected_6089351-20141008065244.log:0026352033AC162DB137C820141008043244.6310+020000,CHEM-SPEC,Normal,+27873549997,,Originating,+27873549997,Anonymous,0313143300,20141008043244.631,0+020000,No,,20141008043249.766,003,VoIP,,0313143300,interlat,to,0313143300,,remote,10.0.108.11:5060,BW063244650081014-982165185@196.35.130.5,G729/8000,10.0.12.135,C4B3D509-4DDA11E4-B93EF6CA-EBABF7F8@197.96.243.105,,,,CHEM-SPEC-DBN,,,,,,,,,,n,public,,4289634633:0,,Ordinary,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,873549997@isvoip.net,,,,,,,,,,,,,,CHEM-SPEC-DBN/BT-CHEM-SPEC,,,,,,,,,,,,,,,,,,,,,,25.136,,,,,,,,,,,,,,,,,,,,,,,,,Normal,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Network,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0873549997@10.0.12.135:5060,Primary Device,0.000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Cisco-SIPGateway/IOS-15.3.3.M2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,|Y,ACCOUNT NOT FOUND (9)
-bash-3.2$

---------- Post updated at 04:53 PM ---------- Previous update was at 04:49 PM ----------

Field 12 Can either be Yes or No but i would like to get all the lines which has field 12 = No and delete this lines from BW*2014*.log and place them into No_Answer.csv
# 5  
Old 10-08-2014
It helps if you were to specify the actual field delmiter and a sample of the file instead of the grep.

It seems you are using , (comma as the field delimiter)
So
Code:
awk -F\, "{print $12}" <file-name>

yields the entry for determining filter.
Just pointing that out.
This User Gave Thanks to blackrageous For This Post:
# 6  
Old 10-08-2014
I am sure it must be a more elegant solution and more efficient.

If I understood correctly, you want to rename the file BW*2014*.csv if the field 12 is "No" and remove those lines matching.
Code:
# Check if field 12 is "No" and redirect the output
awk 'BEGIN{FS=","} $12 != "No"' BW*2014*.csv > output

# Compare the output with the original. If those files are different that is that a line was matched and removed, so then the original file has to be renamed.

if ! cmp -s output BW*2014*.csv
then
  mv BW*2014*.csv No_Answer.csv 
fi

I wanted to try a different approach unsuccesfully trying to evaluate the match and exit inside awk that I presume must be more efficient but it did not work.

I emulated the situation like this:

Code:
echo -e "a b c\nd 3 f\ng h i" | awk 'BEGIN{if($2 != "e"){exit 2}}'; echo $?
echo -e "a b c\nd e f\ng h i" | awk 'BEGIN{if($2 != "e"){exit 2}}'; echo $?

But it always prints 2 unfortunately.

It may be interesting to provide a solution with the exit status inside awk.

Any awk master around?
This User Gave Thanks to Kibou For This Post:
# 7  
Old 10-08-2014
Quote:
Originally Posted by Kibou

....

I emulated the situation like this:

Code:
echo -e "a b c\nd 3 f\ng h i" | awk 'BEGIN{if($2 != "e"){exit 2}}'; echo $?
echo -e "a b c\nd e f\ng h i" | awk 'BEGIN{if($2 != "e"){exit 2}}'; echo $?

But it always prints 2 unfortunately.

It may be interesting to provide a solution with the exit status inside awk.

Any awk master around?
Remove BEGIN block it should work, its executed before reading anything

This was supposed to be

Code:
echo -e "a b c\nd e f\ng h i" | awk '$2 != "e"{exit 2}'; echo $?

---------- Post updated at 01:35 AM ---------- Previous update was at 01:31 AM ----------

above return exit code 2 and following returns zero

Code:
echo -e "a e 1" | awk '$2 != "e"{exit 2}'; echo $?
0

---------- Post updated at 01:37 AM ---------- Previous update was at 01:35 AM ----------

From manual


A BEGIN rule is executed once only, before the first input record is read. Likewise, an END rule is executed once only, after all the input is read.
These 2 Users Gave Thanks to Akshay Hegde For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Problem with getting awk to multiply a field by a value set based on condition of another field

Hi, So awk is driving me crazy on this one. I have searched everywhere and read man, docs and every related post Google can find and still no luck. The actual files I need to run this on are sensitive in nature, but it is the same thing as if I needed to calculate weighted grades for multiple... (15 Replies)
Discussion started by: cotilloe
15 Replies

2. Shell Programming and Scripting

awk to update field using matching value in file1 and substring in field in file2

In the awk below I am trying to set/update the value of $14 in file2 in bold, using the matching NM_ in $12 or $9 in file2 with the NM_ in $2 of file1. The lengths of $9 and $12 can be variable but what is consistent is the start pattern will always be NM_ and the end pattern is always ;... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. Shell Programming and Scripting

awk to adjust coordinates in field based on sequential numbers in another field

I am trying to output a tab-delimited result that uses the data from a tab-delimited file to combine and subtract specific lines. If $4 matches in each line then the first matching sequential $6 value is added to $2, unless the value is 1, then the original $2 is used (like in the case of line... (3 Replies)
Discussion started by: cmccabe
3 Replies

4. Shell Programming and Scripting

Display combination of 4 field uniqe record and along with concatenate 5th and 6th field.

Table ACN|NAME|CITY|CTY|NO1|NO2 115|AKKK|ASH|IND|10|15 115|AKKK|ASH|IND|20|20 115|AKKK|ASH|IND|30|35 115|AKKK|ASH|IND|30|35 112|ABC|FL|USA|15|15 112|ABC|FL|USA|25|20 112|ABC|FL|USA|25|45 i have written shell script using cut command and awk programming getting error correct it and add... (5 Replies)
Discussion started by: udhal
5 Replies

5. Shell Programming and Scripting

Command/script to match a field and print the next field of each line in a file.

Hello, I have a text file in the below format: Source Destination State Lag Status CQA02W2K12pl:D:\CAQA ... (10 Replies)
Discussion started by: pocodot
10 Replies

6. Linux

How do I format a Date field of a .CSV file with multiple commas in a string field?

I have a .CSV file (file.csv) whose data are all enclosed in double quotes. Sample format of the file is as below: column1,column2,column3,column4,column5,column6, column7, Column8, Column9, Column10 "12","B000QRIGJ4","4432","string with quotes, and with a comma, and colon: in... (3 Replies)
Discussion started by: dhruuv369
3 Replies

7. Shell Programming and Scripting

Plz Help. Compare 2 files field by field and get the output in another file.

Hi Freinds, I have 2 files . one is source.txt and second one is target.txt. I want to keep source.txt as baseline and compare target.txt. please find the data in 2 files and Expected output. Source.txt 1|HYD|NAG|TRA|34.5|1234 2|CHE|ESW|DES|36.5|134 3|BAN|MEH|TRA|33.5|234... (5 Replies)
Discussion started by: i150371485
5 Replies

8. Shell Programming and Scripting

AWK: Pattern match between 2 files, then compare a field in file1 as > or < field in file2

First, thanks for the help in previous posts... couldn't have gotten where I am now without it! So here is what I have, I use AWK to match $1 and $2 as 1 string in file1 to $1 and $2 as 1 string in file2. Now I'm wondering if I can extend this AWK command to incorporate the following: If $1... (4 Replies)
Discussion started by: right_coaster
4 Replies

9. Shell Programming and Scripting

awk, comma as field separator and text inside double quotes as a field.

Hi, all I need to get fields in a line that are separated by commas, some of the fields are enclosed with double quotes, and they are supposed to be treated as a single field even if there are commas inside the quotes. sample input: for this line, 5 fields are supposed to be extracted, they... (8 Replies)
Discussion started by: kevintse
8 Replies

10. Shell Programming and Scripting

Sort alpha on 1st field, numerical on 2nd field (sci notation)

I want to sort alphabetically on the first field and sort in descending numerical order on the 2nd field. With a normal "sort -r -n" it does this: abc ||| 5e-05 ||| bla abc ||| 3 ||| ble def ||| 1 ||| abc def ||| 0.2 ||| def As you can see it ignores the fact that 5e-05 is actually 0.00005... (1 Reply)
Discussion started by: FrancoisCN
1 Replies
Login or Register to Ask a Question