Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello ,

I have data that look like the floowing exepmles :

a ;kkkhkhk ;hgvhgvhgvh ;123 ;t

a ;bbbg ;yuj ;1237

x ;25 ;z ;t

I want to count the occurrences of ";"(semicolon) in every line. and, when the number of the given character is above 4, it should store the corresponding line into a file .

I have tried the code below :

awk -F ';' 'NF==31' $nom'_temp2.csv' > $nom'_temp3.csv'

it did work on command line but not in crontab.

Waiting for a solution.
Thanks you in advance

What I have tried:

awk -F ';' 'NF==31' $nom'_temp2.csv' > $nom'_temp3.csv'
Posted
Updated 30-Mar-17 0:49am

1 solution

This should work:
Python
awk -F ';' 'NF > 4 {print}' myinputfile > myoutputfile

This sets the field separator to semicolon and then outputs all the lines only where are more than 4 fields i.e. at least 4 semicolons.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900