Sponsored Content
Top Forums Shell Programming and Scripting Trying to do a count on multiple lines in a file Post 302395672 by scottzx7rr on Tuesday 16th of February 2010 03:44:10 PM
Old 02-16-2010
Unfortunately I can't search for anything specific in those lines cause it can be a port(80, 8080, etc...) or service name(https, dns, etc...)

Here is what I was working with and it works except for it pulls the members and the closed bracket } with it also. So I am getting incorrect data. I am not sure how to do it cleanly.

Code:
sed -n '/members/,/}/p' $CONF|wc -l

Code:
bash-3.00# sed -n '/members/,/}/p' input.txt |wc -l
     20

Code:
sed -n '/members/,/}/p' $CONF|more

Quote:
members
1.1.1.1:https
1.1.1.2:https
1.1.1.3:https
1.1.1.4:https
1.1.1.5:https
1.1.1.6:https
}
members
1.1.2.4:https
}
members
1.1.3.4:https
members
1.1.4.4:https
members
1.1.5.4:https
}
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

count lines of file

dear all, i want to count the lines of a flat(text) file using awk.i have tried with {print NR} but its taking lot of time for a big file like 2GB file size. so i want better efficiency...so can any body please help me with some other and better awk code? Regards, Pankaj (15 Replies)
Discussion started by: panknil
15 Replies

2. UNIX for Dummies Questions & Answers

trying to count lines in multiple files

Hi there, I need help. I want to run the command: less filename | wc -l But on multiple files in a directory So to get those files I would run ls -ltr | grep filename_2000123 or of course ls -ltr *filename_2000123* But I am having a problem running a loop to get a count of each... (1 Reply)
Discussion started by: llsmr777
1 Replies

3. UNIX for Dummies Questions & Answers

grep command to find multiple strings in multiple lines in a file.

I want to search files (basically .cc files) in /xx folder and subfolders. Those files (*.cc files) must contain #include "header.h" AND x() function. I am writing it another way to make it clear, I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies

4. Solaris

WC -l does not count all the lines in a file? HELP

I have a file that I need to merge with another like file. Normally I remove the trailer reocrd and merge the file and update the trailer record of the second file. I did a WC -l on the first file before I removed the trailer record, and again afterwards. The count came back the same. I opened the... (6 Replies)
Discussion started by: Harleyrci
6 Replies

5. Shell Programming and Scripting

Multiple pattern matching using awk and getting count of lines

Hi , I have a file which has multiple rows of data, i want to match the pattern for two columns and if both conditions satisfied i have to add the counter by 1 and finally print the count value. How to proceed... I tried in this way... awk -F, 'BEGIN {cnt = 0} {if $6 == "VLY278" &&... (6 Replies)
Discussion started by: aemunathan
6 Replies

6. Shell Programming and Scripting

Awk match multiple columns in multiple lines in single file

Hi, Input 7488 7389 chr1.fa chr1.fa 3546 9887 chr5.fa chr9.fa 7387 7898 chrX.fa chr3.fa 7488 7389 chr21.fa chr3.fa 7488 7389 chr1.fa chr1.fa 3546 9887 chr9.fa chr5.fa 7898 7387 chrX.fa chr3.fa Desired Output 7488 7389 chr1.fa chr1.fa 2 3546 9887 chr5.fa chr9.fa 2... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

7. Shell Programming and Scripting

Count lines from multiple files (3)

Hey everyone, I've to count lines from string of files names then to show sum output of lines. for example: read x = F1 F2 F3 F1 = 12 lines F2 = 14 lines F3 = 10 lines = 36 what I did is: read x echo $x >|temp for x in $(cat temp) do wc -l < $x (3 Replies)
Discussion started by: Aviv
3 Replies

8. Shell Programming and Scripting

Removing multiple lines from input file, if multiple lines match a pattern.

GM, I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed. I am assuming that sed, awk or even perl could do what I need. I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Discussion started by: jxfish2
7 Replies

9. Shell Programming and Scripting

awk joining multiple lines based on field count

Hi Folks, I have a file with fields as follows which has last field in multiple lines. I would like to combine a line which has three fields with single field line for as shown in expected output. Please help. INPUT hname01 windows appnamec1eda_p1, ... (5 Replies)
Discussion started by: shunya
5 Replies

10. Shell Programming and Scripting

Shell script count lines and sum numbers from multiple files

I want to count the number of lines, I need this result be a number, and sum the last numeric column, I had done to make this one at time, but I need to make this for a crontab, so, it has to be an script, here is my lines: It counts the number of lines: egrep -i String file_name_201611* |... (5 Replies)
Discussion started by: Elly
5 Replies
dcheck(8)						      System Manager's Manual							 dcheck(8)

Name
       dcheck - check directory consistency

Syntax
       /etc/dcheck [ -i numbers ] [ filesystem ]

Description
       The command is obsoleted for normal consistency checking by

       The command reads the directories in a file system and compares the link-count in each i-node with the number of directory entries by which
       it is referenced.  If the file system is not specified, a set of default file systems is checked.

       The -i flag is followed by a list of i-numbers; when one of those i-numbers turns up in a directory, the number, the i-number of the direc-
       tory, and the name of the entry are reported.

       The program is fastest if the raw version of the special file is used, since the i-list is read in large chunks.

Diagnostics
       When  a	file  turns  up for which the link-count and the number of directory entries disagree, the relevant facts are reported.  Allocated
       files which have 0 link-count and no entries are also listed.  The only dangerous situation occurs when there are more entries than  links.
       If entries are removed, so the link-count drops to 0, the remaining entries point to nothing.  They should be removed.  When there are more
       links than entries, or there is an allocated file with neither links nor entries, some disk space may be lost but the  situation  will  not
       degenerate.

Restrictions
       Since is inherently two-pass in nature, extraneous diagnostics may be produced if applied to active file systems.

Files
       Default file systems vary with installation.

See Also
       fs(5), clri(8), fsck(8), icheck(8), ncheck(8)

																	 dcheck(8)
All times are GMT -4. The time now is 06:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy