![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| First occurence of character in a file | dhanamurthy | Shell Programming and Scripting | 6 | 05-13-2008 12:56 AM |
| counting the occurence of particular characters | Audra | UNIX for Dummies Questions & Answers | 2 | 03-28-2008 10:01 AM |
| first occurence and line number | mercuryshipzz | Shell Programming and Scripting | 9 | 01-22-2008 07:42 PM |
| Counting position of a character | rochitsharma | UNIX for Advanced & Expert Users | 3 | 11-27-2007 06:26 PM |
| Counting occurence of a coma | dbrundrett | Shell Programming and Scripting | 3 | 01-22-2004 05:40 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Counting occurence of a particular character on each line
Hi,
I have the following data in a flat file: Code:
abcd_efgh_ijkl_20080522.dat|20080602222508|1357 abcd_efgh_ijkl_20080522.dat|20080602222508|1357 abcd_efgh_ijkl_20080522.dat|20080602222508|1357 Code:
2|abcd_efgh_ijkl_20080522.dat|20080602222508|1357 2|abcd_efgh_ijkl_20080522.dat|20080602222508|1357 2|abcd_efgh_ijkl_20080522.dat|20080602222508|1357 Can anyone help me on this? Thanks in advance Last edited by Yogesh Sawant; 06-26-2008 at 04:44 AM.. Reason: added code tags |
|
||||
|
Hi Radoulov,
Thanks for your reply. It works the way I want. It might happen the flat file may have irregular no. of columns like below: abcd_efgh_ijkl_20080522.dat|20080602222508|1357 abcd_efgh_ijkl_20080522.dat|20080602222508|1357 abcd_efgh_ijkl_20080522.dat|20080602222508|1357 abcd_efgh_ijkl_20080522.dat|20080602222508|1357|1357|1357 abcd_efgh_ijkl_20080522.dat|20080602222508|1357|1357 abcd_efgh_ijkl_20080522.dat|20080602222508 If I run your command, it gives me correct output as: 2|abcd_efgh_ijkl_20080522.dat|20080602222508|1357 2|abcd_efgh_ijkl_20080522.dat|20080602222508|1357 2|abcd_efgh_ijkl_20080522.dat|20080602222508|1357 4|abcd_efgh_ijkl_20080522.dat|20080602222508|1357|1357|1357 3|abcd_efgh_ijkl_20080522.dat|20080602222508|1357|1357 1|abcd_efgh_ijkl_20080522.dat|20080602222508 The flat file should contain fixed number of columns, i.e. always 3, but it may also have the possibility of having the above irregular columns. So I need to find the lines which are having irregular no. of columns, i.e. having <> 3. Last output required is: 4|abcd_efgh_ijkl_20080522.dat|20080602222508|1357|1357|1357 3|abcd_efgh_ijkl_20080522.dat|20080602222508|1357|1357 1|abcd_efgh_ijkl_20080522.dat|20080602222508 I hope I am able to provide proper details. Can I get the solution to the above problem? Thanks in advance |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|