Sponsored Content
Top Forums Shell Programming and Scripting awk evaluating a string as a math expression Post 302841227 by avi.levi on Wednesday 7th of August 2013 07:45:25 AM
Old 08-07-2013
Quote:
Originally Posted by rdcwayx
Code:
awk -F "[:[]" '/:/{"echo $(("$2"))"|getline var;$2="[" var ":"}1' OFS= infile

wire        [31:0]       jerry_AWADDR;
wire                       jerry_AWVALID;
wire         [3:0]       jerry_AWCACHE;
wire         [3:0]       jerry_AWID;
wire         [3:0]       jerry_AWLEN;
wire         [1:0]       jerry_AWLOCK;
wire         [2:0]       jerry_AWPROT;
wire         [2:0]       jerry_AWSIZE;
wire         [2:0]       jerry_AWBURST;
wire        [63:0]       jerry_WDATA;
wire         [63:0]       jerry_WID;
wire                       jerry_WLAST;
wire         [7:0]       jerry_WSTRB;
wire                       jerry_WVALID;
wire                       jerry_BREADY;

It did not work for me.
I am getting blanks where the evaluated number should be.
Are you running a certain version of awk?

Thank you.

---------- Post updated at 06:45 AM ---------- Previous update was at 05:08 AM ----------

Quote:
Originally Posted by rdcwayx
Code:
awk -F "[:[]" '/:/{"echo $(("$2"))"|getline var;$2="[" var ":"}1' OFS= infile

This does not work for me.
I am getting blanks where the evaluated number should be:

Code:
wire        [:0]       jerry_AWADDR;
wire                       jerry_AWVALID;
wire         [:0]       jerry_AWCACHE;
wire         [:0]       jerry_AWID;
wire         [:0]       jerry_AWLEN;
wire         [:0]       jerry_AWLOCK;
wire         [:0]       jerry_AWPROT;
wire         [:0]       jerry_AWSIZE;
wire         [:0]       jerry_AWBURST;
wire        [:0]       jerry_WDATA;
wire         [:0]       jerry_WID;
wire                       jerry_WLAST;
wire         [:0]       jerry_WSTRB;
wire                       jerry_WVALID;
wire                       jerry_BREADY;

Which version of awk are you using?

Thank you.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

String math help needed

#!/usr/bin/ksh #LOGFILE=/var/opt/ixos/log/notification_warning.log #DAT1=/var/opt/ixos/monitor/percentages.dat #DAT2=/var/opt/ixos/monitor/mountpoints.dat THRESHOLD=75 #`rm $DAT1` #`rm $DAT2` `bdf | grep /var/opt/ixos | awk '{ print $4 }' | cut -f1 -d"%" > test.dat` `bdf | grep... (1 Reply)
Discussion started by: petachi
1 Replies

2. Shell Programming and Scripting

How can awk search a string without using regular expression?

Hello, Awk seem treat the pattern as regular expression, how can awk search not using regular expression? e.g. just represent for "", not "A" or "a" . I don't want to add backslash . (2 Replies)
Discussion started by: 915086731
2 Replies

3. UNIX for Dummies Questions & Answers

awk logic and math help

Hi, My file has 2 fields and millions of lines. variableStep chrom=Uextra span=25 201 0.5952 226 0.330693 251 0.121004 276 0.0736858 301 0.0646982 326 0.0736858 401 0.2952 426 0.230693 451 0.221004 476 0.2736858 Each field either has a... (6 Replies)
Discussion started by: wyarosh
6 Replies

4. Shell Programming and Scripting

awk math operation on two files

Hi, I need your help. I've got two files and i need to add 2nd line after occurrence of "Group No X" from data2.txt to 3rd line (after occurrence of "Group No X") from data1.txt. There is the same number of "Groups" in both files and the numbers of groups have the same pattern. data1.txt Group... (2 Replies)
Discussion started by: killerbee
2 Replies

5. Shell Programming and Scripting

Need help with AWK math

I am trying to do some math, so that I can compare the average of six numbers to a variable. Here is what it looks like (note that when I divide really big numbers, it isn't a real number): $ tail -n 6 named.stats | awk -F\, '{print$1}' 1141804 1140566 1139429 1134210 1084682 895045... (3 Replies)
Discussion started by: brianjb
3 Replies

6. Shell Programming and Scripting

awk math and csv output

Hi I have this list 592;1;Z:\WB\DOCS;/FS3_100G/FILER112/BU/MPS/DOCS;;;;\\FILER112\BUMPS-DOCS\;580,116,544,878 Bytes;656,561 ;77,560 592;2;Z:\WB\FOCUS;/FS3_100G/FILER112/BU/MPS/FOCUS;;;;\\FILER112\BUMPS-FOCUS\;172,430 Bytes;6 ;0 ... (12 Replies)
Discussion started by: nakaedu
12 Replies

7. Solaris

Korn shell - evaluating string gives wrong results due to limitations

Anyone ever seen this? Someone mentioned this the other day.... If you do, for instance, in korn shell, echo $(5.2+2.5), it gives the result of 6 regardless. Can't remember why but it was the limitation of the korn shell. (5 Replies)
Discussion started by: psychocandy
5 Replies

8. Shell Programming and Scripting

Count math using awk

Hi expert, I have log : TOTAL-TIME : 2125264636 DATA-BYTES-DOWN : 3766111307032 DATA-BYTES-UP : 455032157567 DL = (3766111307032/2125264636)/1024 = 1.73 UL = (455032157567/2125264636)/1024 = 0.21 I want the result : TOTAL = 1.94 ... (4 Replies)
Discussion started by: justbow
4 Replies

9. Shell Programming and Scripting

Math count %memory using awk

Hi expert, i have log this: Memory: 74410384 Memory: 75831176 Memory: 77961232 Memory: 77074656 Memory: 76086160 Memory: 77128592 Memory: 78045384 Memory: 76696040 Memory: 72401176 Memory: 72520016 Memory: 72137016 Memory: 73175832 Memory: 73034528 Memory: 71770736 Memory:... (4 Replies)
Discussion started by: justbow
4 Replies

10. UNIX for Dummies Questions & Answers

awk If expression - Return string if not true

Hi, I have the following txt file List_With_Duplicates.txt; a,1,1 b,3,4 c,5,2 d,6,1 e,3,3 f,3,7 When I run the command awk -F ',' '{if($2==$3){print $1","$2","$3}}' List_With_Duplicates.txt I get the following output; a,1,1 e,3,3 This works! as I've compared the 2nd & 3rd... (7 Replies)
Discussion started by: mmab
7 Replies
Net::DNS::DomainName(3) 				User Contributed Perl Documentation				   Net::DNS::DomainName(3)

NAME
Net::DNS::DomainName - DNS domain name wire representation SYNOPSIS
use Net::DNS::DomainName; $object = new Net::DNS::DomainName('example.com'); $name = $object->name; $data = $object->encode; ( $object, $next ) = decode Net::DNS::DomainName( $data, $offset ); DESCRIPTION
The Net::DNS::DomainName module implements the concrete representation of DNS domain names used within DNS packets. Net::DNS::DomainName defines methods for encoding and decoding wire format octet strings as defined in RFC1035. All other behaviour, including the new() constructor, is inherited from Net::DNS::Domain. The Net::DNS::DomainName1035 and Net::DNS::DomainName2535 packages implement disjoint domain name subtypes which provide the name compression and canonicalisation specified by RFC1035 and RFC2535. These are necessary to meet the backward compatibility requirements introduced by RFC3597. METHODS
new $object = new Net::DNS::DomainName('example.com'); Creates a domain name object which identifies the domain specified by the character string argument. decode $object = decode Net::DNS::DomainName( $buffer, $offset, $hash ); ( $object, $next ) = decode Net::DNS::DomainName( $buffer, $offset, $hash ); Creates a domain name object which represents the DNS domain name identified by the wire-format data at the indicated offset within the data buffer. The argument list consists of a reference to a scalar containing the wire-format data and specified offset. The optional reference to a hash table provides improved efficiency of decoding compressed names by exploiting already cached compression pointers. The returned offset value indicates the start of the next item in the data buffer. encode $data = $object->encode; Returns the wire-format representation of the domain name suitable for inclusion in a DNS packet buffer. Net::DNS::DomainName1035 Net::DNS::DomainName1035 implements a subclass of domain name objects which are to be encoded using the compressed wire format defined in RFC1035. use Net::DNS::DomainName; $object = new Net::DNS::DomainName1035('compressible.example.com'); $data = $object->encode( $offset, $hash ); ( $object, $next ) = decode Net::DNS::DomainName1035( $data, $offset ); Note that RFC3597 implies that the RR types defined in RFC1035 section 3.3 are the only types eligible for compression. encode $data = $object->encode( $offset, $hash ); Returns the wire-format representation of the domain name suitable for inclusion in a DNS packet buffer. The optional arguments are the offset within the packet data where the domain name is to be stored and a reference to a hash table used to index compressed names within the packet. If the hash reference is undefined, encode() returns the lowercase uncompressed canonical representation defined in RFC2535(8.1). Net::DNS::DomainName2535 Net::DNS::DomainName2535 implements a subclass of domain name objects which are to be encoded using uncompressed wire format. Note that RFC3597, and latterly RFC4034, specifies that the lower case canonical encoding defined in RFC2535 is to be used for RR types defined prior to RFC3597. use Net::DNS::DomainName; $object = new Net::DNS::DomainName2535('incompressible.example.com'); $data = $object->encode( $offset, $hash ); ( $object, $next ) = decode Net::DNS::DomainName2535( $data, $offset ); encode $data = $object->encode( $offset, $hash ); Returns the uncompressed wire-format representation of the domain name suitable for inclusion in a DNS packet buffer. If the hash reference is undefined, encode() returns the lowercase canonical form defined in RFC2535(8.1). COPYRIGHT
Copyright (c)2009-2011 Dick Franks. All rights reserved. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
perl, Net::DNS, Net::DNS::Domain, RFC1035, RFC2535, RFC3597, RFC4034 perl v5.16.2 2012-01-27 Net::DNS::DomainName(3)
All times are GMT -4. The time now is 09:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy