Sponsored Content
Top Forums Shell Programming and Scripting Counting number of records with string row delimiter Post 302564044 by durden_tyler on Wednesday 12th of October 2011 04:48:02 PM
Old 10-12-2011
Quote:
Originally Posted by aksforum
..
i have a file like this
t.txt

f1|_f2|_
f1|_f2|_
f1|_f2|_

as if col delimiter is |_ and row delimiter |_\n

trying to count number of records using awk

...wondering how can i count this to 3 ?
...
Code:
$
$ cat t.txt
f1|_f2|_
f1|_f2|_
f1|_f2|_
$
$ awk 'BEGIN {FS="|_"} {print "Record Number: ", NR, "No. of fields = ", NF}' t.txt
Record Number:  1 No. of fields =  3
Record Number:  2 No. of fields =  3
Record Number:  3 No. of fields =  3
$
$

tyler_durden
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count No of Records in File without counting Header and Trailer Records

I have a flat file and need to count no of records in the file less the header and the trailer record. I would appreciate any and all asistance Thanks Hadi Lalani (2 Replies)
Discussion started by: guiguy
2 Replies

2. UNIX for Dummies Questions & Answers

count the number of files which have a search string, but counting the file only once

I need to count the number of files which have a search string, but counting the file only once if search string is found. eg: File1: Please note that there are 2 occurances of "aaa" aaa bbb ccc aaa File2: Please note that there are 3 occurances of "aaa" aaa bbb ccc... (1 Reply)
Discussion started by: sudheshnaiyer
1 Replies

3. Shell Programming and Scripting

Help required for counting delimiter

Hi All, I have a delimited file.Sometime it happens that delimiter get missed between 2 fields,so i need to count the number of delimiter present at each line. exam file.txt a|b|c|d e|f|a cc|dd so output should be 1 3 2 2 3 1 Thanks (2 Replies)
Discussion started by: ravi.sadani19
2 Replies

4. Shell Programming and Scripting

Counting the number of occurances of all characters (a-z) in a string

Hi, I am trying out different scripts in PERL. I want to take a line/string as an input from the user and count the number of occurrances of all the alphabets (a..z) in the string. I tried doingit like this : #! /opt/exp/bin/perl print "Enter a string or line : "; $string = <STDIN>; chop... (5 Replies)
Discussion started by: rsendhilmani
5 Replies

5. Shell Programming and Scripting

Counting records with AWK

I've been working with an awk script and I'm wondeing id it's possible to count records in a file which DO NOT contain, in this instance fields 12 and 13. With the one script I am wanting to display the count for the records WITH fields 12 and 13 and a seperate count of records WITHOUT fields... (2 Replies)
Discussion started by: Glyn_Mo
2 Replies

6. Shell Programming and Scripting

Help me in counting records from file

Hi, Please help me in counting the below records(1st field) from samplefile: Expected output: Count Descr ------------------------------------------- 7 Mean manager 14 ... (7 Replies)
Discussion started by: prashant43
7 Replies

7. Shell Programming and Scripting

Help- counting delimiter in a huge file and split data into 2 files

I’m new to Linux script and not sure how to filter out bad records from huge flat files (over 1.3GB each). The delimiter is a semi colon “;” Here is the sample of 5 lines in the file: Name1;phone1;address1;city1;state1;zipcode1 Name2;phone2;address2;city2;state2;zipcode2;comment... (7 Replies)
Discussion started by: lv99
7 Replies

8. Shell Programming and Scripting

Compare two files with different number of records and output only the Extra records from file1

Hi Freinds , I have 2 files . File 1 |nag|HYd|1|Che |esw|Gun|2|hyd |pra|bhe|3|hyd |omu|hei|4|bnsj |uer|oeri|5|uery File 2 |nag|HYd|1|Che |esw|Gun|2|hyd |uer|oi|3|uery output : (9 Replies)
Discussion started by: i150371485
9 Replies

9. Shell Programming and Scripting

Counting number of single quotes in a string

i need to be able to count the number of single quotes ' in the entire string below: "description":"DevOps- Test VM's, System Admins Test VM's ", awk can most likely do this, but here's my attempt using egrep: echo "${STRING}" | egrep -wc '"'"\'"'"' or echo "${STRING}" | egrep -wc... (11 Replies)
Discussion started by: SkySmart
11 Replies

10. UNIX for Dummies Questions & Answers

I want count of number of records to be printed on each row.

we want the count of number of records to be printed on each row. For Ex: if there are 5 records on one unique id , the count "5'' should be printed on each record in other column. Please help for this. I am using unix & Cygwin. Below are sample records: KCZ0650473... (2 Replies)
Discussion started by: ElijaRajesh
2 Replies
Jifty::Action::Record::Execute(3pm)			User Contributed Perl Documentation		       Jifty::Action::Record::Execute(3pm)

NAME
Jifty::Action::Record::Execute - Simple abstract based for record actions SYNOPSIS
use strict; use warnings; package MyApp::Action::StartEncabulator; use base qw/ MyApp::Action::ExecuteEncabulator /; use Jifty::Param::Schema; use Jifty::Action schema { param cardinal_grammeter_mode => type is 'text', valid_values are qw/ magneto-reluctance capacitive-duractance sinusoidal-depleneration /, is mandatory, ; }; sub take_action { my $self = shift; my $mode = $self->argument_value('cardinal_grammeter_mode'); $self->record->start($mode); $self->result->success('Deluxe Encabulator has started!'); } # Later in your templates: my $encabulator = MyApp::Model::Encabulator->new; $encabulator->load($id); my $startup = Jifty->web->new_action( class => 'StartEncabulator', record => $encabulator, ); Jifty->web->form->start; Jifty->web->out( $startup->form_field('cardinal_grammeter_mode') ); Jifty->web->form->submit( label => _('Start'), submit => $startup, ); Jifty->web->form->end; DESCRIPTION
This action class is a good generic basis for creating custom action classes. It expects a record object to be associated and is (in this way) very similar to Jifty::Action::Record::Delete. You can use Jifty::Param::Schema to add additional form fields to the action and such. METHODS
arguments This is customized so that it expects the "record" argument of all Jifty::Action::Record actions, but also allows for overrides using Jifty::Param::Schema. take_action This overrides the definition in Jifty::Action::Record so that it does absolutely nothing rather than complain. You will probably want to implement your own version that actually does something. SEE ALSO
Jifty::Action, Jifty::Action::Record, Jifty::Record LICENSE
Jifty is Copyright 2005-2010 Best Practical Solutions, LLC. Jifty is distributed under the same terms as Perl itself. perl v5.14.2 2010-12-10 Jifty::Action::Record::Execute(3pm)
All times are GMT -4. The time now is 06:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy