Sponsored Content
Top Forums Shell Programming and Scripting Get values block by block in same file Post 302905089 by Akshay Hegde on Monday 9th of June 2014 02:19:21 PM
Old 06-09-2014
So what would be the expected output for given new input ?

Whether this is what you are looking for ?

Code:
$ awk -F'/' 'function isnum(x){return(x==x+0)}/P1/,/P2/{if(!/P1|P2/ && /10,9:.*/)print "value"++i,":",isnum($NF)?$NF:"NULL"}' file
value1 : 18013013582
value2 : 13233361170

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to append a block of statements after another block in the file

Hi I need to append the following block of statements in the middle of the file: # openpipe tsdbdwn2 set -x exec >> /tmp/tsdbdwn2.fifo 2>&1 # This needs to be appended right after another block of statements: if test $# -eq 0 ;then echo "Safety check - do you really wish to run" $0 "... (5 Replies)
Discussion started by: aoussenko
5 Replies

2. Shell Programming and Scripting

finding a block in a file and replace with another file block.

(1) Yes but how is this block different from the other 24? You will need this information in order to identify and replace this block correctly (out of the 25). Ans: The 1st line and last line of this block are unique from other block. The 1st line is “rem Subset Rows (&&tempName.*) and The... (1 Reply)
Discussion started by: Zaheer.mic
1 Replies

3. Shell Programming and Scripting

Getting values from a block into variables

Hi there, If I run "ipmitool bmc info" on any of my x86 boxes, i get Device ID : 32 Device Revision : 1 Firmware Revision : 1.1 IPMI Version : 2.0 Manufacturer ID : 42 Manufacturer Name : Sun Microsystems Product ID ... (7 Replies)
Discussion started by: rethink
7 Replies

4. UNIX for Advanced & Expert Users

Deciding whether to get a buffer cache block or inode block

I was reading a book on UNIX internals "The design of the UNIX Operating system." There are two memory structures that are confusing me: 1) Buffer cache 2) Inode cache My questions are 1) Does a process get both buffer cache and Indoe cache allocated when it opens/creates a file? 2) if no,... (1 Reply)
Discussion started by: sreeharshasn
1 Replies

5. Shell Programming and Scripting

Grepping text block by block by using for loop

Hei buddies, Need ur help once again. I have a file which has bunch of lines which starts from a fixed pattern and ends with another fixed pattern. I want to make use of these fixed starting and ending patterns to select the bunch, one at a time. The input file is as follows. Hi welcome... (12 Replies)
Discussion started by: anushree.a
12 Replies

6. UNIX for Advanced & Expert Users

Move a block of lines to file if string found in the block.

I have a "main" file which has blocks of data for each user defined by tags BEGIN and END. BEGIN ID_NUM:24879 USER:abc123 HOW:47M CMD1:xyz1 CMD2:arp2 STATE:active PROCESS:id60 END BEGIN ID_NUM:24880 USER:def123 HOW:4M CMD1:xyz1 CMD2:xyz2 STATE:running PROCESS:id64 END (7 Replies)
Discussion started by: grep_me
7 Replies

7. Shell Programming and Scripting

Printing a block of lines from a file, if that block does not contain two patterns using sed

I want to process a file block by block using sed, and if that block does not contain two patterns, then that complete block has to be printed. See below for the example data. ................................server 1............................... running process 1 running... (8 Replies)
Discussion started by: Kesavan
8 Replies

8. Shell Programming and Scripting

Formatting and replacing according to block values

please consider the following file, there are repeated blocks of m values, and nested s values within. there are 2 columns (cols 3 and 4)associated with each m,s combination. All s1 rows must get a value of a(col 3 in output), all s2 values must get a value of b(col 3 in output). If s1 and s2 rows... (1 Reply)
Discussion started by: senhia83
1 Replies

9. UNIX for Dummies Questions & Answers

Add a block of code at the end of a specific block

I need to search for a block with the starting pattern say "tabId": "table_1", and ending pattern say "]" and then add a few lines before "]" "block1":"block_111" "tabId": "table_1", "title":"My title" ..... .... }] how do I achieve it using awk and sed. Thanks, Lakshmi (3 Replies)
Discussion started by: Lakshmikumari
3 Replies

10. Shell Programming and Scripting

Find specific pattern and change some of block values using awk

Hi, Could you please help me finding a way to replace a specific value in a text block when matching a key pattern ? I got the keys and the values from a command similar to: echo -e "key01 Nvalue01-1 Nvalue01-2 Nvalue01-3\nkey02 Nvalue02-1 Nvalue02-2 Nvalue02-3 \nkey03 Nvalue03-1... (2 Replies)
Discussion started by: alex2005
2 Replies
Scalar::Util::Numeric(3pm)				User Contributed Perl Documentation				Scalar::Util::Numeric(3pm)

NAME
Scalar::Util::Numeric - numeric tests for Perl scalars SYNOPSIS
use Scalar::Util::Numeric qw(isnum isint isfloat); foo($bar / 2) if (isnum $bar); if (isint $baz) { # ... } elsif (isfloat $baz) { # ... } DESCRIPTION
This module exports a number of wrappers around perl's builtin "grok_number" function, which returns the numeric type of its argument, or 0 if it isn't numeric. TAGS
All of the functions exported by Scalar::Util::Numeric can be imported by using the ":all" tag: use Scalar::Util::Numeric qw(:all); EXPORTS
isnum isnum ($val) Returns a nonzero value (indicating the numeric type) if $val is a number. The numeric type is a conjunction of the following flags: 0x01 IS_NUMBER_IN_UV (number within UV range - not necessarily an integer) 0x02 IS_NUMBER_GREATER_THAN_UV_MAX (number is greater than UV_MAX) 0x04 IS_NUMBER_NOT_INT (saw . or E notation) 0x08 IS_NUMBER_NEG (leading minus sign) 0x10 IS_NUMBER_INFINITY (Infinity) 0x20 IS_NUMBER_NAN (NaN - not a number) isint isuv isbig isfloat isneg isinf isnan The following flavours of "isnum" (corresponding to the flags above) are also available: isint isuv isbig isfloat isneg isinf isnan "isint" returns -1 if its operand is a negative integer, 1 if it's 0 or a positive integer, and 0 otherwise. The others always return 1 or 0. SEE ALSO
o "type" in autobox o Data::Types o Params::Classify o Params::Util o Scalar::Util o String::Numeric VERSION
0.22 AUTHORS
o chocolateboy <chocolate@cpan.org> o Michael G Schwern <schwern@pobox.com> COPYRIGHT
Copyright (c) 2005-2010, chocolateboy. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. perl v5.14.2 2010-08-25 Scalar::Util::Numeric(3pm)
All times are GMT -4. The time now is 08:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy