Sponsored Content
Top Forums Shell Programming and Scripting Blocks of text in a file - extract when matches... Post 302903757 by CarloM on Thursday 29th of May 2014 11:23:20 AM
Old 05-29-2014
You can pass the shell variables in using -v.

Like:
Code:
$ export SERVICEID=54321; awk -vRS="-------" -vVAR1=$SERVICEID '$0 ~ "Service ID: ("VAR1")" {match ($0, /start_date[^\n]*/); print substr ($0, RSTART, RLENGTH)} ' input.txt
start_date: 0xdde9 20:00:00 (Sun Jun 1 21:00:00 2014)

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract if pattern matches

Hi All, I have an input below. I tried to use the awk below but it seems that it ;s not working. Can anybody help ? My concept here is to find the 2nd field of the last occurrence of such pattern " ** XXX ccc ccc cc cc ccc 2007 " . In this case, the 2nd field is " XXX ". With this "XXX" term... (20 Replies)
Discussion started by: Raynon
20 Replies

2. Shell Programming and Scripting

Delete blocks of lines from text file

Hello, Hello Firends, I have file like below. I want to remove selected blocks say abc,pqr,lst. how can i remove those blocks from file. zone abc { blah blah blah } zone xyz { blah blah blah } zone pqr { blah blah blah } (4 Replies)
Discussion started by: nrbhole
4 Replies

3. Shell Programming and Scripting

Extract sequence blocks

Hi, I have an one-line file consisting of a sequence of 660 letters. I would like to extract 9-letter blocks iteratively: ASDFGHJKLQWERTYUIOPZXCVBNM first block: ASDFGHJKL 1nd block: SDFGHJKLQ What I have so far only gives me the first block, can anyone please explain why? cat... (7 Replies)
Discussion started by: solli
7 Replies

4. 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

5. 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

6. Shell Programming and Scripting

Extract sequences of bytes from binary for differents blocks

Hello to all, I would like to search sequences of bytes inside big binary file. The bin file contains blocks of information, each block begins is estructured as follow: 1- Each block begins with the hex 32 (1 byte) and ends with FF. After the FF of the last block, it follows 33. 2- Next... (59 Replies)
Discussion started by: Ophiuchus
59 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

9. Shell Programming and Scripting

Extract all the sentences from a text file that matches a pattern list

Hi I have a big text file. I want to extract all the sentences that matches at least 70% (seventy percent) of the words from each sentence based on a word list called A. Say the format of the text file is as given below: This is the first sentence which consists of fifteen words... (4 Replies)
Discussion started by: my_Perl
4 Replies

10. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies
TORRUS_SRVDERIVE(8)						      torrus						       TORRUS_SRVDERIVE(8)

NAME
srvderive - Derive a new service ID from sum or maximum of other service values SYNOPSIS
torrus srvderive TIMESPAN OUTPUT FUNCTION SOURCES... DESCRIPTION
When the Torrus Reporting engine is set up, this command is used to combine several services data into a new service ID. The output data is either the maximum or the sum of input services. See Torrus Reporting Setup Guide for more information. TIMESPAN
Either --month or --end option must be defined --start=YYYY-MM-DD Sets the start date of the calculation. --end=YYYY-MM-DD Sets the next day after the eond of the period. --month Instead of setting the end data, it is convenient to use this option. It sets the end data in one calendar month after the start date. OUTPUT
--out=SERVICEID Sets the output service ID. This should not be a service ID used in the Torrus datasource trees. Note: if srvderive command is run twice with the same arguments, the produced data is doubled for the output service ID. FUNCTION
--func="MAX"|"SUM" Sets the function to be used when combining the input service data. Currently only "MAX" and "SUM" are supportted. SOURCES
--in=SERVICEID ... Input service IDs are specified either by --in option, or as command line arguments. At least 2 input service IDs should be specified. OPTIONS
--step Default: 300. Sets the data interval for derived service ID. It is recommended to leave this option at default value. --verbose Prints extra informatgion. --debug Prints debugging information. --help Prints command usage information. SEE ALSO
torrus(8) NOTES
See more documentation at Torrus home page: http://torrus.org AUTHOR
Stanislav Sinyagin <ssinyagin@yahoo.com> torrus 2.03 2013-07-26 TORRUS_SRVDERIVE(8)
All times are GMT -4. The time now is 12:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy