Sponsored Content
Full Discussion: Rta data needs regexp
Top Forums Shell Programming and Scripting Rta data needs regexp Post 302888853 by RudiC on Monday 17th of February 2014 06:25:15 PM
Old 02-17-2014
Quote:
Originally Posted by ashokvpp
Code:
echo "rta=58.124001ms;100.000000;150.000000;0.000000 pl=0%;5;15;0" | awk -F"[=;]" ' { print $2, $NF } '
58.124001ms 0

I just required 58.12 and 0.00 - Could you please assist.
You didn't print that desired 0.000000 but the last single 0 that was not present in your post #1's sample.
Code:
rta=58.124001ms;100.000000;150.000000;0.000000 pl=0%;5;15;0"
                                      ^-desired           ^-printed

With this sample, even anbu23's formatted printout would not deliver the correct value. If the correct value is last in line, the proposals will work fine, if it's not, you need to supply more conditions how to identify it.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

regexp

Hi guys, does anyone know how to test for a regular expression - i want to include it in a script to make sure the variable is a regexp cheers (1 Reply)
Discussion started by: penfold
1 Replies

2. Shell Programming and Scripting

Need Help with Perl REGEXP

I need help with a Perl regular expression. The following string blows up my program: <david(greg jim)> If I type this string, there is no problem: <david(greg_jim)> or type david(gregjim) or type <david greg jim> the CGI program does not complain. For some reason that I do not understand the... (1 Reply)
Discussion started by: mh53j_fe
1 Replies

3. Shell Programming and Scripting

regexp with sed again!!!

please help: I want to add 1 space between string and numbers: input file: abcd12345 output file: abcd 1234 The following sed command does not work: sed 's/\(+\)\(+\)/\1 \2/' file Any ideas, please Andy (2 Replies)
Discussion started by: andy2000
2 Replies

4. Shell Programming and Scripting

regexp help

I'd like to know if there is a catchall line for renaming the following patterns: s01e03 -> 01x03 s4e9 -> 04x09 s10e08 ->10x08 and possibly even: 318 -> 03x18 1002 ->10x02 if its the first 3 or first digit number in the string. thanks! (0 Replies)
Discussion started by: TinCanFury
0 Replies

5. Shell Programming and Scripting

Help with regexp

Hi there! I would like to know how to find and replace all numbers in a *.html file and make them bold. Any help will be appreciated! :) (7 Replies)
Discussion started by: agasamapetilon
7 Replies

6. UNIX for Dummies Questions & Answers

print the line immediately after a regexp; but regexp is a sentence

Good Day, Im new to scripting especially awk and sed. I just would like to ask help from you guys about a sed command that prints the line immediately after a regexp, but not the line containing the regexp. sed -n '/regexp/{n;p;}' filename What if my regexp is 3 word or a sentence. Im... (3 Replies)
Discussion started by: ownins
3 Replies

7. Shell Programming and Scripting

printing data between 2 occurances of regexp

Hi, I an new to this forum and i need help with awk regex processing. I am trying to print chunk of data between occurances of reg expression for example: regex chunkofdata1 regexp chunkofdata2 regexp i want to print "chunkofdata1" to file1 , "chunkofdata2" to file2 .. and so on ... (2 Replies)
Discussion started by: ss1984
2 Replies

8. Shell Programming and Scripting

Need help with sed and regexp

Hi everyone, I would really appreciate any help I could get on the following topic. I am not very familiar with reg expressions nor with sed, I just know the basic uses. What I am trying to do is the following: I have a huge text file where I would like to replace all occurnces of a certain... (13 Replies)
Discussion started by: Boxtuna
13 Replies

9. Shell Programming and Scripting

Regexp

I would like to extract "1333 Fairlane" given the below text. The word "Building:" is always present. The wording between Building and the beginning of the address can be almost anything. It appears the the hyphen is there most of the time. Campus: Fairlane Business Park Building:... (9 Replies)
Discussion started by: bbaker@copesan.
9 Replies

10. What is on Your Mind?

A Regexp You Can Use Everywhere

¯\_(ツ)_/¯ bakunin (0 Replies)
Discussion started by: bakunin
0 Replies
RTNETLINK(3)						     Linux Programmer's Manual						      RTNETLINK(3)

NAME
rtnetlink - macros to manipulate rtnetlink messages SYNOPSIS
#include <asm/types.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> #include <sys/socket.h> rtnetlink_socket = socket(AF_NETLINK, int socket_type, NETLINK_ROUTE); int RTA_OK(struct rtattr *rta, int rtabuflen); void *RTA_DATA(struct rtattr *rta); unsigned int RTA_PAYLOAD(struct rtattr *rta); struct rtattr *RTA_NEXT(struct rtattr *rta, unsigned int rtabuflen); unsigned int RTA_LENGTH(unsigned int length); unsigned int RTA_SPACE(unsigned int length); DESCRIPTION
All rtnetlink(7) messages consist of a netlink(7) message header and appended attributes. The attributes should be only manipulated using the macros provided here. RTA_OK(rta, attrlen) returns true if rta points to a valid routing attribute; attrlen is the running length of the attribute buffer. When not true then you must assume there are no more attributes in the message, even if attrlen is nonzero. RTA_DATA(rta) returns a pointer to the start of this attribute's data. RTA_PAYLOAD(rta) returns the length of this attribute's data. RTA_NEXT(rta, attrlen) gets the next attribute after rta. Calling this macro will update attrlen. You should use RTA_OK to check the validity of the returned pointer. RTA_LENGTH(len) returns the length which is required for len bytes of data plus the header. RTA_SPACE(len) returns the amount of space which will be needed in a message with len bytes of data. CONFORMING TO
These macros are nonstandard Linux extensions. BUGS
This manual page is incomplete. EXAMPLE
Creating a rtnetlink message to set the MTU of a device: #include <linux/rtnetlink.h> ... struct { struct nlmsghdr nh; struct ifinfomsg if; char attrbuf[512]; } req; struct rtattr *rta; unsigned int mtu = 1000; int rtnetlink_sk = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE); memset(&req, 0, sizeof(req)); req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); req.nh.nlmsg_flags = NLM_F_REQUEST; req.nh.nlmsg_type = RTM_NEWLINK; req.if.ifi_family = AF_UNSPEC; req.if.ifi_index = INTERFACE_INDEX; req.if.ifi_change = 0xffffffff; /* ??? */ rta = (struct rtattr *)(((char *) &req) + NLMSG_ALIGN(req.nh.nlmsg_len)); rta->rta_type = IFLA_MTU; rta->rta_len = sizeof(unsigned int); req.n.nlmsg_len = NLMSG_ALIGN(req.nh.nlmsg_len) + RTA_LENGTH(sizeof(mtu)); memcpy(RTA_DATA(rta), &mtu, sizeof(mtu)); send(rtnetlink_sk, &req, req.nh.nlmsg_len); SEE ALSO
netlink(3), netlink(7), rtnetlink(7) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2010-01-11 RTNETLINK(3)
All times are GMT -4. The time now is 03:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy