-2

I have a CSV file like below

05032020
Col1|col2|col3|col4|col5

 Infosys
 Tcs
 Wipro
 Accenture
 Deloitte

I want record count by skipping date and Header columns

O/p: Record count 5 with including line numbers

cat FF_Json_to_CSV_MAY03.txt

05032020 requestId|accountBranch|accountNumber|guaranteeGuarantor|accountPriority|accountRelationType|accountType|updatedDate|updatedBy

0000000001|5BW|52206|GG1|02|999|CHECKING|20200503|BTCHLCE 0000000001|55F|80992|GG2|02|1999|IRA|20200503|0QLC 0000000001|55F|24977|CG|01|3999|CERTIFICAT|20200503|SRIKANTH 0000000002|5HJ|03349|PG|01|777|SAVINGS|20200503|BTCHLCE 0000000002|5M8|999158|GG3|01|900|CORPORATE|20200503|BTCHLCE 0000000002|5LL|49345|PG|01|999|CORPORATE|20200503|BTCHLCE 0000000002|5HY|15786|PG|01|999|CORPORATE|20200503|BTCHLCE 0000000003|55F|34956|CG|01|999|CORPORATE|20200503|SRIKANTH 0000000003|5BY|14399|GG10|03|10|MONEY MARK|20200503|BTCHLCE 0000000003|5PE|32100|PG|04|999|JOINT|20200503|BTCHLCE 0000000003|5LB|07888|GG25|02|999|BROKERAGE|20200503|BTCHLCE 0000000004|55F|36334|CG|02|999|JOINT|20200503|BTCHLCE 0000000005|55F|06739|GG9|02|999|SAVINGS|20200503|BTCHLCE 0000000005|5CP|39676|PG|01|999|SAVINGS|20200503|BTCHLCE 0000000006|55V|62452|CG|01|10|CORPORATE|20200503|SRIKANTH 0000000007|55V|H9889|CG|01|999|SAVINGS|20200503|BTCHLCE 0000000007|5L2|03595|PG|02|999|CORPORATE|20200503|BTCHLCE 0000000007|55V|C1909|GG8|01|10|JOINT|20200503|BTCHLCE

I need line numbers from 00000000001

1 Answers1

0

There are two ways to solve your issue:

  • Count only the records you want to count
  • Count all records and remove the ones you don't want to count

From your example, it's not possible to know how to do it, but let me give you some ideas:

Imagine that your file starts with 3 header lines, then you can do something like:

wc -l inputfile | awk '{print $1-3}'

Imagine that the lines you want to count all start with a number and a dot, then you can do something like:

grep "[0-9]*\." inputfile | wc -l
Dominique
  • 16,450
  • 15
  • 56
  • 112