Sponsored Content
Top Forums Shell Programming and Scripting total number of lines in a file Post 302139027 by vino on Thursday 4th of October 2007 06:06:54 AM
Old 10-04-2007
Quote:
Originally Posted by radoulov
Code:
zsh 4.3.4% cat file
a

b
zsh 4.3.4% wc -l file
3 file
zsh 4.3.4% grep -c . file
2

may be something like:

Code:
zsh 4.3.4% grep -c ^ file
3

and it's not bulletproof either ...
Hmm..Smilie my input file had empty lines or so I thought. It had the ^M characters which resulted into the same result for both wc and grep. Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Total of lines w/out header and footer incude for a file

I am trying to get a total number of tapes w/out headers or footers in a ERV file and append it to the file. For some reason I cannot get it to work. Any ideas? #!/bin/sh dat=`date +"%b%d_%Y"` + date +%b%d_%Y dat=Nov16_2006 tapemgr="/export/home/legato/tapemgr/rpts"... (1 Reply)
Discussion started by: gzs553
1 Replies

2. Shell Programming and Scripting

total number of lines

Hi have following file |abcd 2|abcd |sdfh |sdfj I want to find total number of files haivng nothing in feild 1 using awk will command awk -F "|" '( $1=="") {print NR}' test_awk will work??? (4 Replies)
Discussion started by: mahabunta
4 Replies

3. Shell Programming and Scripting

Appending line number to each line and getting total number of lines

Hello, I need help in appending the line number of each line to the file and also to get the total number of lines. Can somebody please help me. I have a file say: abc def ccc ddd ffff The output should be: Instance1=abc Instance2=def Instance3=ccc Instance4=ddd Instance5=ffff ... (2 Replies)
Discussion started by: chiru_h
2 Replies

4. Shell Programming and Scripting

Number lines of file and assign variable to each number

I have a file with a list of config files numbered on the lefthand side 1-300. I need to have bash read each lines number and assign it to a variable so it can be chosen by the user called by the script later. Ex. 1 some data 2 something else 3 more stuff which number do you... (1 Reply)
Discussion started by: glev2005
1 Replies

5. Shell Programming and Scripting

perl script on how to count the total number of lines of all the files under a directory

how to count the total number of lines of all the files under a directory using perl script.. I mean if I have 10 files under a directory then I want to count the total number of lines of all the 10 files contain. Please help me in writing a perl script on this. (5 Replies)
Discussion started by: adityam
5 Replies

6. Shell Programming and Scripting

Select lines in which column have value greater than some percent of total file lines

i have a file in following format 1 32 3 4 6 4 4 45 1 45 4 61 54 66 4 5 65 51 56 65 1 12 32 85 now here the total number of lines are 8(they vary each time) Now i want to select only those lines in which the values... (6 Replies)
Discussion started by: vaibhavkorde
6 Replies

7. Shell Programming and Scripting

Help with sum total number of record and total number of record problem asking

Input file SFSQW 5192.56 HNRNPK 611.486 QEQW 1202.15 ASDR 568.627 QWET 6382.11 SFSQW 4386.3 HNRNPK 100 SFSQW 500 Desired output file SFSQW 10078.86 3 QWET 6382.11 1 QEQW 1202.15 1 HNRNPK 711.49 2 ASDR 568.63 1 The way I tried: (2 Replies)
Discussion started by: patrick87
2 Replies

8. UNIX for Dummies Questions & Answers

Write the total number of rows in multiple files into another file

Hello Friends, I know you all are busy and inteligent too... I am stuck with one small issue if you can help me then it will be really great. My problem is I am having some files i.e. Input.txt1 Input.txt2 Input.txt3 Now my task is I need to check the total number of rows in... (4 Replies)
Discussion started by: malaya kumar
4 Replies

9. Shell Programming and Scripting

quickest way to get the total number of lines in a file

i have a file that's about 2GB, i have to get the total number of lines in this file every 10 minutes. the interval is not an issue. i just need the proper, most efficient way to do this. any ideas? i got the following from another thread on this site, but: awk 'int(100*rand())%5<1'... (12 Replies)
Discussion started by: SkySmart
12 Replies

10. UNIX for Dummies Questions & Answers

How to find count total number of pattern in a file …?

How to find count total number of pattern in a file … File contains : a.txt ------------- aaa bbb nnn ccc aaa bbb aaa ddd aaa aaa aaa aaa grep -c aaa a.txt Op: 4 ( But my requirement is should count the total no of patterns as 7 ) (4 Replies)
Discussion started by: Jitten
4 Replies
Perl::Critic::Statistics(3pm)				User Contributed Perl Documentation			     Perl::Critic::Statistics(3pm)

NAME
Perl::Critic::Statistics - Compile stats on Perl::Critic violations. DESCRIPTION
This class accumulates statistics on Perl::Critic violations across one or more files. NOTE: This class is experimental and subject to change. INTERFACE SUPPORT
This is considered to be a non-public class. Its interface is subject to change without notice. METHODS
"new()" Create a new instance of Perl::Critic::Statistics. No arguments are supported at this time. " accumulate( $doc, @violations ) " Accumulates statistics about the $doc and the @violations that were found. "modules()" The number of chunks of code (usually files) that have been analyzed. "subs()" The total number of subroutines analyzed by this Critic. "statements()" The total number of statements analyzed by this Critic. "lines()" The total number of lines of code analyzed by this Critic. "lines_of_blank()" The total number of blank lines analyzed by this Critic. This includes only blank lines in code, not POD or data. "lines_of_comment()" The total number of comment lines analyzed by this Critic. This includes only lines whose first non-whitespace character is "#". "lines_of_data()" The total number of lines of data section analyzed by this Critic, not counting the "__END__" or "__DATA__" line. POD in a data section is counted as POD, not data. "lines_of_perl()" The total number of lines of Perl code analyzed by this Critic. Perl appearing in the data section is not counted. "lines_of_pod()" The total number of lines of POD analyzed by this Critic. Pod occurring in a data section is counted as POD, not as data. "violations_by_severity()" The number of violations of each severity found by this Critic as a reference to a hash keyed by severity. "violations_by_policy()" The number of violations of each policy found by this Critic as a reference to a hash keyed by full policy name. "total_violations()" The the total number of violations found by this Critic. "statements_other_than_subs()" The total number of statements minus the number of subroutines. Useful because a subroutine is considered a statement by PPI. "average_sub_mccabe()" The average McCabe score of all scanned subroutines. "violations_per_file()" The total violations divided by the number of modules. "violations_per_statement()" The total violations divided by the number statements minus subroutines. "violations_per_line_of_code()" The total violations divided by the lines of code. AUTHOR
Elliot Shank "<perl@galumph.com>" COPYRIGHT
Copyright (c) 2007-2011 Elliot Shank. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. perl v5.14.2 2012-06-07 Perl::Critic::Statistics(3pm)
All times are GMT -4. The time now is 03:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy