![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How count number of fields in a record | sureshg_sampat | Shell Programming and Scripting | 5 | 01-07-2008 03:30 AM |
| help me to count no of fields in a file | babu@shell | Shell Programming and Scripting | 7 | 10-30-2006 10:36 PM |
| How to count the record count in an EBCDIC file. | oracle8 | UNIX for Dummies Questions & Answers | 1 | 07-26-2006 04:22 PM |
| How to add fields in a file | bjorb | Shell Programming and Scripting | 2 | 10-13-2005 05:11 AM |
| count fields | sskb | UNIX for Dummies Questions & Answers | 4 | 12-07-2001 09:40 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Get count on different fields along the raws in a file
Dear All,
Please help me to do this. I have a file like this. 5|94662240807|94776109911|94776325901|94779007172|||||| 5|94112925421|94352240384|94352259199|94672229012|||||| 5|94714242745|94722952461|94777660793|94788914465|||||| 5|94242224624|94776145420|94776172499|94776531059|||||| so i want to get the count on 9477 number as result from each raw. result ==== 3 0 1 3 Thanks, Nayanajith. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Which language : Shell, Perl, Awk, ... ?
|
|
#3
|
|||
|
|||
|
shell .. (bash)
|
|
#4
|
||||
|
||||
|
Code:
nawk '{print gsub("9477", "")}' myFile.txt
|
|
#5
|
|||
|
|||
|
#! /usr/bin/ksh
while read line do echo $line |awk -F"9477" '{print NF-1}' done < file Last edited by alamitab; 02-08-2008 at 06:38 AM. |
|
#6
|
||||
|
||||
|
Or:
Code:
awk '{print NF-1}' FS=9477 filename
|
|
#7
|
|||
|
|||
|
the best solution
|
|||
| Google The UNIX and Linux Forums |