Sponsored Content
Top Forums Shell Programming and Scripting Working with individual blocks of text using awk Post 302495595 by sandeepk1611 on Thursday 10th of February 2011 04:55:17 PM
Old 02-10-2011
Working with individual blocks of text using awk

Hi,

I am working with CVS log data and have some data as follows.

Code:
RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/core/IBreakpointListener.java,v
head: 1.14
branch:
locks: strict
access list:
keyword substitution: o
total revisions: 15;    selected revisions: 2
description:
----------------------------
revision 1.14
date: 2006-06-12 15:42:24 -0500;  author: darin;  state: Exp;  lines: +2 -2;
copyright updates
----------------------------
revision 1.13
date: 2006-05-16 09:34:00 -0500;  author: darin;  state: Exp;  lines: +1 -1;
javadoc spelling errors
=============================================================================
RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/core/IBreakpointManager.java,v
head: 1.36
branch:
locks: strict
access list:
keyword substitution: o
total revisions: 38;    selected revisions: 4
description:
----------------------------
revision 1.31
date: 2007-03-26 20:47:29 -0500;  author: darin;  state: Exp;  lines: +1 -1;  commitid: 61604608779a4567;
update copyrights
----------------------------
revision 1.30
date: 2007-01-17 09:01:45 -0600;  author: darin;  state: Exp;  lines: +3 -2;  commitid: 614345ae3a564567;
javadoc settings and fixes
----------------------------
revision 1.29
date: 2006-06-12 15:42:24 -0500;  author: darin;  state: Exp;  lines: +2 -2;
copyright updates
----------------------------
revision 1.28
date: 2006-05-16 09:34:00 -0500;  author: darin;  state: Exp;  lines: +1 -1;
javadoc spelling errors
=============================================================================
RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/core/IBreakpointManagerListener.java,v
head: 1.6
branch:
locks: strict
access list:
keyword substitution: kv
total revisions: 6;    selected revisions: 1
description:
----------------------------
revision 1.4
date: 2005-02-23 23:58:22 -0600;  author: darins;  state: Exp;  lines: +1 -1;
CPL --> EPL

A block starts with the word RCS and ends with the pattern ======
I used the following command

awk '/.java,v/,/====/'

and it extracted all the blocks of data for java files i.e. starting and ending with the pattern ======. This is good.

However, I also want to extract some more information from each block and store that also.
For example, I want to count how many revisions are there in each block, how many distinct authors worked on that file, how many lines added/deleted in total for each file, etc.

Can anyone help me out how to extract this information from each block and store that in a tab separated file? Even if I do not get the values of the individual revisions/author names, etc. it is ok. I just want to get the count for revisions (total or the sum of lines added, etc).

Any starting help on even how to work with these individual blocks will be useful. Do I have to use some for loop to work with each block?

Thanks,
Sandeep
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script not working from crontab, executes individual

Hi, This script is working successfully when i executed from shell prompt, but the same script scheduled in crontab its not deleting the files, #! /bin/bash DAY_1=`(date --date='4 months ago' '+%Y-%m')` log=/tmp/cleant adir=/u01/app/oracle/admin/talon/adump... (4 Replies)
Discussion started by: saha
4 Replies

2. Shell Programming and Scripting

extract blocks of text from a file

Hi, This is part of a large text file I need to separate out. I'd like some help to build a shell script that will extract the text between sets of dashed lines, write that to a new file using the whole or part of the first text string as the new file name, then move on to the next one and... (7 Replies)
Discussion started by: cajunfries
7 Replies

3. Shell Programming and Scripting

How to read text in blocks

Hi, I have file which contains information written in blocks (every block is different). Is it possible to read every block one by one to another file (one block per file). The input is something like this <block1> <empty line> <block2> <empty line> ... ... ... <block25> <empty... (0 Replies)
Discussion started by: art84_)LV
0 Replies

4. Shell Programming and Scripting

how to split this file into blocks and then send these blocks as input to the tool called Yices?

Hello, I have a file like this: FILE.TXT: (define argc :: int) (assert ( > argc 1)) (assert ( = argc 1)) <check> # (define c :: float) (assert ( > c 0)) (assert ( = c 0)) <check> # now, i want to separate each block('#' is the delimeter), make them separate files, and then send them as... (5 Replies)
Discussion started by: paramad
5 Replies

5. Shell Programming and Scripting

Concatenate text between patterns in individual strings

In any given file, wherever a certain data block exists I need to concatenate the values(text after each "=" sign) from that block. in that block. The block starts and ends with specific pattern, say BEGIN DS and END DS respectively. The block size may vary. A file will have multiple such blocks.... (12 Replies)
Discussion started by: Prev
12 Replies

6. Shell Programming and Scripting

Transpose lines from individual blocks to unique lines

Hello to all, happy new year 2013! May somebody could help me, is about a very similar problem to the problem I've posted here where the member rdrtx1 and bipinajith helped me a lot. https://www.unix.com/shell-programming-scripting/211147-map-values-blocks-single-line-2.html It is very... (3 Replies)
Discussion started by: Ophiuchus
3 Replies

7. Shell Programming and Scripting

Adding and removing blocks of text from file

Hello all, short story: I'm writing a script to add and remove dns records in dns files. Its on a RHEL 5.5 So far i've locked up the basic operations in a couple of functions: - validate the parameters - search for existant ip in file when adding - search for existant name records in... (6 Replies)
Discussion started by: maverick72
6 Replies

8. Shell Programming and Scripting

How to remove duplicate text blocks from a file?

Hi All I have a list of files which will have duplicate list of blocks of text. Following is a sample of the file, I have removed the sensitive information from the file. All the code samples starts from <TR BGCOLOR="white"> and Ends with IP address and two html tags like this. 10.14.22.22... (3 Replies)
Discussion started by: mahasona
3 Replies
CVSCONNECT(1)															     CVSCONNECT(1)

NAME
cvsconnect - CVS connection minimizer SYNOPSIS
cvsconnect cvsroot [command-to-run ...] DESCRIPTION
CVSconnect enables you to do multiple CVS operations on single network connection. CVSconnect sets up special environment using $CVSRSH/$CVSROOT for the command line CVS client. In the environment, the command line CVS client reuses a network connection. CVSconnect is especially designed to use with CVSsuck. And CVSconnect (or similar) will be integrated to a future version of CVSsuck. However, it is planned that CVSsuck directly connects to a cvs server without cvs command. EXAMPLES
cvsconnect $HOME/.cvsroot BUGS
o The global option -z for compression cannot be used. If you use SSH via ext method, you can use compression by SSH instead. o CVS client must be run at a time. Running two or more clients at a same time will make a trouble. (will be fixed in future release.) o Some static variables in a CVS server may confuse you. It's a CVS bug. Report it to CVS developer :-). o Command line CVS client must request `Root' first. Don't mind. There is no implementation which violates this assumption, however I know. At least, CVS-1.10 and CVS-1.11 should work. NOTES
o When CVS command is failed, CVSconnect automatically re-run the command with reconnected connection when CVS command is failed. Especially the failure is caused by a long running CVS-1.10 server. Since CVS-1.10 doesn't close some file descriptors, a long running CVS server will exceed a limit of file descriptors. o /bin/sh should be POSIX sh because this script uses ${parameter#pattern}, etc. If your /bin/sh is ancient Bourne shell, use ksh or bash. SEE ALSO
cvs(1), cvssuck(1). AUTHOR
This manpage is written by Piotr Roszatycki <dexter@debian.org> for Debian distribution and can be freely redistributed. Debian 2011-08-30 CVSCONNECT(1)
All times are GMT -4. The time now is 08:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy