Sponsored Content
Top Forums UNIX for Beginners Questions & Answers To get the id value dynamically Post 303031823 by stomp on Wednesday 6th of March 2019 06:59:53 AM
Old 03-06-2019
If you really want the id of the newest match, take RudiCs snippet. If you just assume that the first match is the newest, you can go simpler by using that:

Code:
awk 'match($0,/<a href="([0-9]+)/,res) {print res[1];exit}' data.html

If someone wants to use a parser for more robust operation, one can use this as a starting point:
Code:
xmlstarlet sel -t -v "/html/body/pre" data.html  | awk '/^\s*[0-9]+\// {print $1,$2}'


# output 

1456/ 01-Mar-2019
4561/ 28-Feb-2019

Note: I assume only gnu awk supports match(subject,pattern,array) Other variants of awk only support 2 parameter match like match(subject,pattern), which will cause a syntax error here.

Last edited by stomp; 03-06-2019 at 08:34 AM..
These 2 Users Gave Thanks to stomp For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

getting value from field dynamically

how i do pass in field number when cutting, I tried to do this: but it says 11-1: not found (12 Replies)
Discussion started by: finalight
12 Replies

2. Shell Programming and Scripting

Spliting the file dynamically

i am creating the file , when this file reaches the size 2 GB, i need one message or fire (4 Replies)
Discussion started by: kingganesh04
4 Replies

3. Shell Programming and Scripting

Dynamically locating a file

Hi, I have a requriement where in I need to install a s/w by executing the installable file through a script. The script currently contains the path of the installable file. I need to now update the script accordingly such tht it identifies the location of the installable file automatically and... (1 Reply)
Discussion started by: yoursdavinder
1 Replies

4. Shell Programming and Scripting

set array name dynamically

Hi, I am trying to name a set of arrays dynamically named as @array_$i (The $i will mean that I obtain a set of arrays called: @array_1 @array_2 @array_3 etc. i tried various methods like @array_$i @{array_$i} etc. any ways to do this Thanks (4 Replies)
Discussion started by: esham
4 Replies

5. Shell Programming and Scripting

Dynamically create arrays

I have a bash challenge. I have several virtualization hosts for which I need to collect VM information. I need to dynamically create an array for each host. The contents of the array should be the list VMs running on the host. Here's the logic; I just need someone to help me with the details:... (0 Replies)
Discussion started by: EdgarTorres
0 Replies

6. Programming

Dynamically allocated structures in C

I have a pointer to a structure containing an integer pointer: struct members { int id; int *neigh; }; The number of members N and its neighbors M change as the code runs, so I allocate the memory dynamically: members *grid = malloc(sizeof(members)*N); for(i=0;i<N;i++)... (2 Replies)
Discussion started by: brinch
2 Replies

7. Shell Programming and Scripting

Dynamically choosing the interpreter

Hi, Is it possible to choose the inerpreter conditionally. For example, if whereis bash returns /usr/bin/bash then i need to choose #!/usr/bin/bash else i need to use #!/usr/bin/sh. Is it possible to achieve in a shell script? Thanks (1 Reply)
Discussion started by: pandeesh
1 Replies

8. Shell Programming and Scripting

Swap of fields dynamically

Dear Friends, I have file a.txt 1|2|3|4|5|6|7|8 a|b|c|d|e|f|g|h i am using the below code to swap the fields in file awk -F\| '{print $5,$1,$2,$3,$4,$6,$7,$8}' OFS=\| a.txt > output.txt output.txt 5|1|2|3|4|6|7|8 e|a|b|c|d|f|g|h The above command is working fine. I am... (4 Replies)
Discussion started by: i150371485
4 Replies

9. Shell Programming and Scripting

How to dynamically name as function in shell?

Hi all, Does anyone know if it possible to append a parameter to a function name? Something like the following: function tnsrec_${SERVICE_NAME} { code.. } Any ideas? (6 Replies)
Discussion started by: jonnyd
6 Replies

10. UNIX and Linux Applications

Concatenation of different reports dynamically

Hi, I have the following reports that get generated every 1 hour and this is my requirement: 1. 5 reports get generated every hour with the names "Report.Dddmmyy.Thhmiss.CTLR" "Report.Dddmmyy.Thhmiss.ACCD" "Report.Dddmmyy.Thhmiss.BCCD" "Report.Dddmmyy.Thhmiss.CCCD"... (1 Reply)
Discussion started by: Jesshelle David
1 Replies
AUTHLIB(3)						      Double Precision, Inc.							AUTHLIB(3)

NAME
authlib - Courier Authentication Library SYNOPSIS
courierauthconfig [[--ldflags] | [--cppflags]] DESCRIPTION
The Courier authentication library consists of two libraries: -lcourierauth Authentication functions. -lcourierauthsasl SASL authentication functions. courierauthconfig --cppflags produces on standard output any necessary compiler flags that are needed to access the courierauth.h and the courierauthsasl.h header files. courierauthconfig --ldflags produces on standard output any necessary compiler flags that are needed to link against the courierauth or courierauthsasl libraries. SEE ALSO
auth_generic(3)[1], auth_login(3)[2], auth_getuserinfo(3)[3], auth_enumerate(3)[4], auth_passwd(3)[5], auth_sasl(3)[6]. NOTES
1. auth_generic(3) auth_generic.html 2. auth_login(3) auth_login.html 3. auth_getuserinfo(3) auth_getuserinfo.html 4. auth_enumerate(3) auth_enumerate.html 5. auth_passwd(3) auth_passwd.html 6. auth_sasl(3) auth_sasl.html Double Precision, Inc. 08/23/2008 AUTHLIB(3)
All times are GMT -4. The time now is 07:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy