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
TIX(3)							       Tix Built-In Commands							    TIX(3)

NAME
tixNoteBook - Create and manipulate tixNoteBook widgets SYNOPSIS
tixNoteBook pathName ?options? STANDARD OPTIONS
The NoteBook widget supports all the standard options of a frame widget. See the options(n) manual entry for details on the standard options. WIDGET-SPECIFIC OPTIONS [-dynamicgeometry dynamicGeometry] If set to false, the size of the Notebook will match the size of the largest page. If set to true, the size of the Notebook will match the size of the current page (therefore, the size may change when the user selects different pages). The default value is false. A setting of true is discouraged. [-ipadx ipadX] The amount of internal horizontal paddings around the sides of the page subwidgets. [-ipady ipadY] The amount of internal vertical paddings around the sides of the page subwidgets. SUBWIDGETS
Name: nbframe Class: tixNoteBookFrame The "note book frame" widget that displays ths tabs of the notebook. Most of the display options of the page tabs are controlled by this subwidget. For example, if you need to choose a different font to display the tab names of the pages, the color of the inactive tabs or the color behind the tabs, you can configure the options of the nbframe subwidget. See the manual page of tixNoteBook- Frame(n) for more details. In addition, all the page subwidgets created as a result of the add command can be accessed by the subwidget command. They are identified by the pageName parameter to the add command. DESCRIPTION
The tixNoteBook command creates a new window (given by the pathName argument) and makes it into a NoteBook widget. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the NoteBook widget such as its cursor and relief. The NoteBook widget can be used to display many windows in a limited space using a "notebook" metaphore. The notebook is divided into a stack of pages (windows). At one time only one of these pages can be shown. The user can navigate through these pages by choosing the vis- ual "tabs" at the top of the NoteBook widget. WIDGET COMMANDS
The tixNoteBook command creates a new Tcl command whose name is the same as the path name of the NoteBook widget's window. This command may be used to invoke various operations on the widget. It has the following general form: pathName option ?arg arg ...? PathName is the name of the command, which is the same as the NoteBook widget's path name. Option and the args determine the exact behavior of the command. The following commands are possible for NoteBook widgets: pathName add pageName ?option value ...? Adds a new notebook page subwidget into the NoteBook widget. Additional parameters may be supplied to configure this page subwid- get. Possible options are: -anchor Specifies how the information in a tab (e.g. text or a bitmap) is to be displayed in the widget. Must be one of the values n, ne, e, se, s, sw, w, nw, or center. For example, nw means display the information such that its top-left corner is at the top-left corner of the widget. -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. -createcmd Specifies a TCL command to be called the first time a page is shown on the screen. This option can be used to delay the cre- ation of the contents of a page until necessary. Therefore, it can be used to speed up interface creation process especially when there are a large number of pages in a NoteBook widget. -image Specifies an image to display on the tab of this page. The image is displayed only if the -label options is not specified. -justify When there are multiple lines of text displayed in a tab, this option determines how the lines line up with each other. Must be one of left, center, or right. Left means that the lines' left edges all line up, center means that the lines' centers are aligned, and right means that the lines' right edges line up. -label Specifies a text label string to display on the tab of this page subwidget. -raisecmd Specifies a TCL command 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 the text displayed in the wid- get, 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, it is wrapped onto the next line, so that no line is longer than the specified length. The value may be speci- fied in any of the 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. pathName cget option Returns the current value of the configuration option given by option.Option may have any of the values accepted by the tixNoteBook command. pathName configure ?option? ?value option value ...? Query or modify the configuration options of the widget. If no option is specified, returns a list describing all of the available options for pathName (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. Option may have any of the values accepted by the tixNoteBook command. pathName delete pageName? Deletes the page identified by pageName. pathName 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 val- ues accepted by the add widget command. pathName pageconfigure pageName ?option? ?value ...? When no option is given, prints out the values of all options of this page. If option is specified with no value, then the command returns the current value of that option. If one or more option-value pairs are specified, then the command modifies the given page's option(s) to have the given value(s); in this case the command returns an empty string. Option may be any of options accepted by the add widget command. pathName pages Returns a list of the names of all the pages. pathName raise pageName Raise the page identified by pageName. pathName raised Returns the name of the currently raised page. pathName subwidget name ?args? When no options are given, this command returns the pathname of the subwidget of the specified name. When options are given, the widget command of the specified subwidget will be called with these options. BINDINGS
[1] When the user pressed the left mouse button over a notebook tab, the notebook page associated with that tab will be raised to the top of the stack of pages. [2] The pages can also be selected using the keyboard. The user can type the <Tab> key to cycle among the set of pages. When the focus appears on the desired page, the user can type <Return> or <space> to select that page. Or, if the user wants to cancel the selec- tion, he/she can type the <Escape> key. KEYWORDS
Tix(n) Tix 4.0 TIX(3)
All times are GMT -4. The time now is 10:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy