Sponsored Content
Top Forums Shell Programming and Scripting Counting a string between 2 strings... Post 302843548 by ny_evan on Tuesday 13th of August 2013 09:09:18 PM
Old 08-13-2013
Counting a string between 2 strings...

I have been working on this for a little while and have been unable to come to a solution. Any help would be appreciated. I am working on a UNIX workstation and have a 30-40 meg text file that I am working with. In my real file there is hundreds of Jobs. Example of input file;

Code:
misc logging data
Job 1 start
Task start
Task stop
Task start
Task stop
Job 1 stop
Other misc logging data
Job 2 start
Task start
Task stop
Job 2 stop
Other misc logging data
Job 3 start
Task start
Task stop
Task start
Task stop
Task start
task stop
Job 3 stop

My desired output is:
Code:
Job 1, 2 Tasks
Job 2, 1 Tasks
Job 3, 3 Tasks

Thanks again...

Last edited by Don Cragun; 08-13-2013 at 11:01 PM.. Reason: Add CODE tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Counting occurences of different strings in a file

Hi, i'd like to know if the following is possible with a shell script, and can't find the answer in the search. Suppose i have a logfile build like this: # 8 :riuyzp1028 # 38 : riuyzp1028 # 25 : riuyvzp1032 # 30 : nlkljpa0202 # 1 : nlklja0205 # 38 : riuyzp1028 # 25 :... (4 Replies)
Discussion started by: Freerider
4 Replies

2. Shell Programming and Scripting

How to concatenate two strings or several strings into one string in B-shell?

like connect "summer" and "winter" to "summerwinter"? Can anybody help me? thanks a lot. (2 Replies)
Discussion started by: fontana
2 Replies

3. Shell Programming and Scripting

Counting the max length of string

Hi all, I have a flat file of 1000 rows. I want to check the length of the 5th column. The one having the longest length , I want to set it as DEFINED PARAMETER. So later I can check others with that particular number only. Any ideas ?? (2 Replies)
Discussion started by: ganesh123
2 Replies

4. UNIX for Dummies Questions & Answers

Counting no of lines between two strings in a file

Hi all, I'm very very new to UNIX and AWK world.Please help me in finding a solution for my problem. I'm having a file like this ----------------------------------------------------------------- ~Version Information VERS. 2.0: CWLS log ASCII Standard -VERSION 2.0 WRAP. ... (4 Replies)
Discussion started by: santyshyam
4 Replies

5. Shell Programming and Scripting

Counting string of a variable

Hi, There is a variable f_name, it store some file names. Value of f_name=a.sql b.sql c.sql....... like this. want to count how many file name the var f_name stores. Without using loop is there any command to count that. (5 Replies)
Discussion started by: Dip
5 Replies

6. UNIX for Dummies Questions & Answers

grep -c script counting string twice instead of once?

I tried this script to get a count of the occurrence of a string in files. I have multiple files in one directory I will use this on. All the filenames begin "invALL.06" The script works, except it counts twice for every one instance of 'Invoice Total'. If there are 5 occurences of 'Invoice... (2 Replies)
Discussion started by: scarletsupra
2 Replies

7. Shell Programming and Scripting

Awk - find string, search lines below string for other strings

What's the easiest way to search a file for a specific string and then look for other instances after that? I want to search for all Virtual Hosts and print out the Server Name and Document Root (if it has that info), while discarding the rest of the info. Basically my file looks like this: ...... (6 Replies)
Discussion started by: Mbohmer
6 Replies

8. UNIX for Dummies Questions & Answers

Help with counting string elements

Hi All, I hv several files which have hundreds of lines each for example>XYZ.abc01 NNNTCGGTNNNNNCCACACACMYACACACCCACACCCACSCARCAC I'd like to exculde the first line beginning with ">" and then for the rest of the lines get a count for each string element. So for the above example I would like... (8 Replies)
Discussion started by: pawannoel
8 Replies

9. UNIX for Dummies Questions & Answers

counting occurrence of characters in a string

Hello, I have a string like this 0:1:2:0:2:2:4:0:0:0:-200:500...... what i want is to break down how many different characters are there and their count. For example for above string it should display 0 - 5 times 1 - 1 times 2 - 3 times 4 - 1 times . . . I am stuck in writing... (8 Replies)
Discussion started by: exit86
8 Replies

10. Shell Programming and Scripting

Counting Instances of a String with AWK

I have a list of URLs and I want to be able to count the number of instances of addresses ending in a certain TLD and output and sort it like so. 5 bdcc.com 48 zrtzr.com 49 rvo.com Input is as so ync.org sduzj.edu sduzj.edu sduzj.edu sduzj.edu sduzj.edu sduzj.edu sduzj.edu... (1 Reply)
Discussion started by: Pjstaab
1 Replies
Padre::Task::LWP(3pm)					User Contributed Perl Documentation				     Padre::Task::LWP(3pm)

NAME
Padre::Task::LWP - Generic HTTP client background processing task SYNOPSIS
# Fire and forget HTTP request Padre::Task::LWP->new( request => HTTP::Request->new( GET => 'http://perlide.org', ), )->schedule; DESCRIPTION
Sending and receiving data via HTTP. METHODS
new my $task = Padre::Task::LWP->new( method => 'GET', url => 'http://perlide.org', ); The "new" constructor creates a Padre::Task for a background HTTP request. It takes a single addition parameter "request" which is a fully-prepared HTTP::Request object for the request. Returns a new Padre::Task::LWP object, or throws an exception on error. request The "request" method returns the HTTP::Request object that was provided to the constructor. response Before the "run" method has been fired the "response" method returns "undef". After the "run" method has been fired the "response" method returns the HTTP::Response object for the LWP::UserAgent request. Typically, you would use this in the "finish" method for the task, if you wish to take any further actions in Padre based on the result of the HTTP call. SEE ALSO
This class inherits from "Padre::Task" and its instances can be scheduled using "Padre::TaskManager". The transfer of the objects to and from the worker threads is implemented with Storable. AUTHOR
Steffen Mueller "smueller@cpan.org" COPYRIGHT AND LICENSE
Copyright 2008-2012 The Padre development team as listed in Padre.pm. This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself. perl v5.14.2 2012-06-27 Padre::Task::LWP(3pm)
All times are GMT -4. The time now is 11:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy