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
tixListNoteBook(n)					       Tix Built-In Commands						tixListNoteBook(n)

__________________________________________________________________________________________________________________________________________________

NAME
tixListNoteBook - Create and manipulate tixListNoteBook widgets SYNOPSIS
tixListNoteBook pathName ?options? STANDARD OPTIONS
The ListNoteBook 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 ListNotebook will match the size of the largest page. If set to true, the size of the ListNotebook 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: hlist Class: TixHList The HList widget that displays the names of the pages. 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 tixListNoteBook command creates a new window (given by the pathName argument) and makes it into a ListNoteBook widget. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the ListNoteBook widget such as its cursor and relief. The ListNoteBook widget is very similar to the TixNoteBook widget: it can be used to display many windows in a limited space using a "note- book" 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 name of the desired page in the hlist subwidget. WIDGET COMMANDS
The tixListNoteBook command creates a new Tcl command whose name is the same as the path name of the ListNoteBook 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 ListNoteBook widget's path name. Option and the args determine the exact behavior of the command. The following commands are possible for ListNoteBook widgets: pathName add pageName ?option value ...? Adds a new ListNotebook page subwidget into the ListNoteBook widget. pageName must be the name of an existing entry of the hlist subwidget. You must create the entry before calling the add command. Please refer to the tixHList(n) manual entry for adding entries in an HList widget. Additional parameters may be supplied to configure this page subwidget. Possible options are: -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 ListNoteBook widget. -raisecmd Specifies a TCL command to be called whenever this page is raised by the user. When successful, this command returns the pathname of the newly created page. pathName cget option Returns the current value of the configuration option given by option.Option may have any of the values accepted by the tixListNote- Book 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 tixListNoteBook 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. EXAMPLE
set n [tixListNoteBook .n]; pack $n $n subwidget hlist add page1 -text "Page 1" $n subwidget hlist add page2 -text "Page 2" set page1 [$n add page1] set page2 [$n add page2] button $page1.b -text "On page1" button $page2.b -text "On page2" pack $page1.b pack $page2.b $n raise page2 BINDINGS
When the user activates an entry in the hlist subwidget, the page associated with that entry will be raised to the front. This can be done by using the mouse or keyboard. The hlist subwidget operates with its -selectmode option set to single. See the event bindings of the HList widget for more details. KEYWORDS
Tix(n), tixHList(n) Tix 4.0 tixListNoteBook(n)
All times are GMT -4. The time now is 09:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy