Sponsored Content
Top Forums Shell Programming and Scripting Counting similar lines from file UNIX Post 302346582 by mohsin.quazi on Sunday 23rd of August 2009 07:53:09 AM
Old 08-23-2009
Lightbulb Counting similar lines from file UNIX

I have a file which contains data as below:

Code:
nbk1j7o pageName=/jsp/RMBS/RMBSHome.jsf
nbk1j7o pageName=/jsp/RMBS/RMBSHome.jsf
nbk1j7o pageName=/jsp/RMBS/RMBSHome.jsf
nbk1j7o pageName=/jsp/RMBS/RMBSHome.jsf
nbk1j7o pageName=/jsp/common/index.jsf
nbk1j7o pageName=/jsp/common/index.jsf
nbk1wqe pageName=/jsp/RMBS/RMBSHome.jsf
nbk1wqe pageName=/jsp/common/index.jsf
nbk2coz pageName=/jsp/RMBS/PassThrough.jsf
nbk2coz pageName=/jsp/RMBS/PassThrough.jsf
nbk2coz pageName=/jsp/RMBS/PassThrough.jsf
nbk2coz pageName=/jsp/RMBS/PassThrough.jsf
nbk2coz pageName=/jsp/RMBS/PassThrough.jsf
nbk2coz pageName=/jsp/RMBS/PassThrough.jsf
nbk2coz pageName=/jsp/RMBS/PassThrough.jsf

I want output like:

--------------------------------------------------------
Code:
NBKID       PAGE ACCESSED                             COUNT
--------------------------------------------------------
nbk1j7o    pageName=/jsp/RMBS/RMBSHome.jsf    4
nbk1j7o    pageName=/jsp/common/index.jsf        2
nbk1wqe  pageName=/jsp/RMBS/RMBSHome.jsf     1
nbk1wqe  pageName=/jsp/common/index.jsf         1
nbk2coz   pageName=/jsp/RMBS/PassThrough.jsf   7



In short, i want to count the similar lines and remove multiple entries and include the count of that particular line.

Last edited by vgersh99; 08-23-2009 at 06:42 PM.. Reason: code tags, PLEASE!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - Counting number of similar lines

Hi All I have the input file OMAK_11. OMAK 000002EXCLUDE 1341 OMAK 000002EXCLUDE 1341 OMAK 000002EXCLUDE 1341 OMAK 000003EXCLUDE 1341 OMAK 000003EXCLUDE 1341 OMAK 000003EXCLUDE ... (8 Replies)
Discussion started by: dhanamurthy
8 Replies

2. Shell Programming and Scripting

How to sort a file and then print similar lines once

Hi! I have a trouble with the sort and the uniq. I know I have to use them, I just have trouble with putting them in the right order. I have a text file with unsorted lines (each line has a few words, the first word in the line is a number.). I need to sort this file in order to be... (6 Replies)
Discussion started by: shira
6 Replies

3. Infrastructure Monitoring

Remove Similar Lines from a File

I have a log file "logreport" that contains several lines as seen below: 04:20:00 /usr/lib/snmp/snmpdx: Agent snmpd appeared dead but responded to ping 06:38:08 /usr/lib/snmp/snmpdx: Agent snmpd appeared dead but responded to ping 07:11:05 /usr/lib/snmp/snmpdx: Agent snmpd appeared dead... (4 Replies)
Discussion started by: Nysif Steve
4 Replies

4. Shell Programming and Scripting

Counting similar lines

Hi, I have a little problem with counting lines. I know similar topics from this forum, but they don't resolve my problem. I have file with lines like this: 2009-05-25 16:55:32,143 some text some regular expressions ect. 2009-05-25 16:55:32,144 some text. 2009-05-28 18:15:12,148 some... (4 Replies)
Discussion started by: marcinnnn
4 Replies

5. Shell Programming and Scripting

remove one of each similar lines in a file

Hello folks I have a question for you gurus of sed or grep (maybe awk, but I would prefer the first two) I have a file (f1) that says: (actually, these are not numbers but md5sum, but for simplicity, let's assume these numbers.) 1 2 3 4 5And I have a file (f2) that says 1|a 1|b 1|c 2|d... (3 Replies)
Discussion started by: tukuyomi
3 Replies

6. UNIX for Dummies Questions & Answers

Matching and reporting near-similar lines in a file

Hi, I have a file with the lines as below: C_10_A05_T7 C_10_A06_SP6 C_10_B05_SP6 C_10_B05_T7 C_10_B01_SP6 C_10_B01_T7 C_12_G07_SP6 C_12_G11_SP6 C_12_G11_T7 C_2_H18_T7 C_2_I02_SP6 C_2_I02_T7 C_2_I13_SP6 C_2_I17_SP6 The four segments of each line are connected by '_' symbols. I... (7 Replies)
Discussion started by: Fahmida
7 Replies

7. Shell Programming and Scripting

extracting lines from a file with similar first name

consider i have two files cat onlyviews1.sql CREATE VIEW V11 AS SELECT id, name, FROM etc etc WHERE etc etc; CREATE VIEW V22 AS SELECT id, name, FROM etc etc WHERE etc etc; CREATE VIEW V33 AS (10 Replies)
Discussion started by: vivek d r
10 Replies

8. Shell Programming and Scripting

removing lines with similar values from file

Hello, got a file with this structure: 33274 171030 02/29/2012 37897 P_GEH 2012-02-29 10:31:26 33275 171049 02/29/2012 38132 P_GEH 2012-02-29 10:35:27 33276 171058 02/29/2012 38515 P_GEH 2012-02-29 10:43:26 33277 170748 02/29/2012 40685 P_KOM ... (3 Replies)
Discussion started by: krecik28
3 Replies

9. Shell Programming and Scripting

Help in unix script to join similar lines of input

Hi, I have been thinking of how to script this but i have no clue at all.. Could someone please help me out or give me some idea on this? I would like to group those lines with the same first variable in each line, joining the 2nd variables with commas. Let's say i have the following input. ... (3 Replies)
Discussion started by: rei125
3 Replies

10. Shell Programming and Scripting

Reducing text file using similar lines

Hello, I am a java programmer but want to try unix for a purpose where I need to reduce a file using its first field.. Here is the sample data: admin;2;0;; admission;8;0;; aman;1;0;; caroline;0;4;; cook;0;4;; cook;2;0;; far;0;3;; far;1;5;; I am explaining the dataset first. There... (5 Replies)
Discussion started by: shekhar2010us
5 Replies
NoteBook(3pm)						User Contributed Perl Documentation					     NoteBook(3pm)

NAME
Tk::NoteBook - display several windows in limited space with notebook metaphor. SYNOPSIS
use Tk::NoteBook; ... $w = $frame->NoteBook(); $page1 = $w->add("page1", options); $page2 = $w->add("page2", options); ... $page2 = $w->add("page2", options); DESCRIPTION
The NoteBook widget provides a notebook metaphor to display several windows in limited space. The notebook is divided into a stack of pages of which only one is displayed at any time. The other pages can be selected by means of choosing the visual "tabs" at the top of the widget. Additionally, the <Tab> key may be used to traverse the pages. If -underline is used, Alt- bindings will also work. The widget takes all the options that a Frame does. In addition, it supports the following options: -dynamicgeometry If set to false (default and recommended), the size of the NoteBook will match the size of the largest page. Otherwise the size will match the size of the current page causing the NoteBook to change size when different pages of different sizes are selected. -ipadx The amount of internal horizontal padding around the pages. -ipady The amount of internal vertical padding around the pages. -backpagecolor The background color of the tabs and back page. -disabledforeground XXX -focuscolor The color of the focus border around the tabs. -font The font of the tab labels. -inactivebackground XXX -tabpadx Horizonzal padding around the tab label. -tabpady Vertical padding around the tab label. METHODS
The following methods may be used with a NoteBook object in addition to standard methods. add(pageName, options) Adds a page with name pageName to the notebook. Returns an object of type Frame. The recognized options are: -anchor Specifies how the information in a tab is to be displayed. Must be one of n, ne, e, se, s, sw, w, nw or center. -bitmap Specifies a bitmap to display on the tab of this page. The bitmap is displayed only if none of the -label or -image options are specified. -image Specifies an image to display on the tab of this page. The image is displayed only if the -label option is not specified. -label Specifies the text string to display on the tab of this page. -justify When there are multiple lines of text displayed in a tab, this option determines the justification of the lines. -createcmd Specifies a callback to be called the first time the page is shown on the screen. This option can be used to delay the creation of the contents of a page until necessary. It can be useful in situations where there are a large number of pages in a NoteBook widget; with -createcmd you do not have to make the user wait until all pages are constructed before displaying the first page. -raisecmd Specifies a callback to be called whenever this page is raised by the user. -state Specifies whether this page can be raised by the user. Must be either normal or disabled. -underline Specifies the integer index of a character to underline in the tab. This option is used by the default bindings to implement keyboard traversal for menu buttons and menu entries. 0 corresponds to the first character of text displayed on the widget, 1 to the next character and so on. -wraplength This option specifies the maximum line length of the label string on this tab. If the line length of the label string exceeds this length, then it is wrapped onto the next line so that no line is longer than the specified length. The value may be specified in any standard forms for screen distances. If this value is less than or equal to 0, then no wrapping is done: lines will break only at newline characters in the text. delete(pageName) Deletes the page identified by pageName. pagecget(pageName, -option) Returns the current value of the configuration option given by -option in the page given by pageName. Option may have any of the values accepted in the add method. pageconfigure(pageName, options) Like configure for the page indicated by pageName. Options may be any of the options accepted by the add method. pages Returns a list consisting of the names of all currently defined pages, i.e., those created with the add method. page_widget(pageName) Returns the page with name pageName. raise(pageName) Raise the page identified by pageName. raised() Returns the name of the currently raised page. geometryinfo Return the dimensions of the tab area. identify(x,y) Identify the tab's page name under the specified coordinates. Return an empty string if there's no tab. info("pages") Return a list of all pages. info("focus") Return the page name of the tab with the current focus. info("focusnext") Return the page name of the tab which would receive the next focus. info("focusprev") Return the page name of the tab which had the previous focus. info("active") Return the page name of the active tab. BUGS
The options "-width" and "-height" do not work. AUTHORS
Rajappa Iyer <rsi@earthling.net> Nick Ing-Simmons <nick@ni-s.u-net.com> This code and documentation was derived from NoteBook.tcl in Tix4.0 written by Ioi Lam. It may be distributed under the same conditions as Perl itself. perl v5.14.2 2010-05-29 NoteBook(3pm)
All times are GMT -4. The time now is 09:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy