Sponsored Content
Top Forums Shell Programming and Scripting Extracting vaules from end of string Post 302986802 by RudiC on Wednesday 30th of November 2016 09:14:19 AM
Old 11-30-2016
Assuming a recent bash: try using an array:
Code:
ARR=( $(snmpwalk -v1 -c public 192.168.0.20 1.3.6.1.2.1.43.11.1.1.8.1.1) )
echo ${ARR[${#ARR[@]}-1]}
1800

EDIT: or
Code:
echo ${ARR[-1]}
1800

This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unique cell vaules in a file

I have a file in which I have records as follows -------------------------------------------------------------------------- 2-sister-birmbb-s0005.ftip002590790.vpn-nte.bt.net BRI0 0 0 0 aber-con-dyce-s0006.ftip002732992.vpn-nte.bt.net ATM0 0 0 0... (3 Replies)
Discussion started by: rahulrathod
3 Replies

2. Shell Programming and Scripting

Extracting a string from one file and searching the same string in other files

Hi, Need to extract a string from one file and search the same in other files. Ex: I have file1 of hundred lines with no delimiters not even space. I have 3 more files. I should get 1 to 10 characters say substring from each line of file1 and search that string in rest of the files and get... (1 Reply)
Discussion started by: mohancrr
1 Replies

3. Shell Programming and Scripting

extracting a string

Hi All, I am writing a shell script for which I am stuck with an extraction part. I arrived till extraction of a path of file. Lets take an example. I now have a file which contains following one line: 2348/home/userid/mydir/any_num_dir/myfile.text Now I want to extract only... (2 Replies)
Discussion started by: start_shell
2 Replies

4. UNIX for Dummies Questions & Answers

reading vaules from a text file.

say i have a text file called "input.txt" 1 5 2 10 3 15 4 20 and say I wanted to read the row 3 from column 2 how would i go about it. I guess I would use "awk" but I'm not sure how. (2 Replies)
Discussion started by: THM
2 Replies

5. Shell Programming and Scripting

Extracting String

I am trying to extract a hyperlink from a html document using awk. I have managed to output in the format... href="index.html"> where i would like it just to output index.html. Any ideas on how i would do this? Thanks (2 Replies)
Discussion started by: adpe
2 Replies

6. Shell Programming and Scripting

Appending string, variable to file at the start and string at end

Hi , I have below file with 13 columns. I need 2-13 columns seperated by comma and I want to append each row with a string "INSERT INTO xxx" in the begining as 1st column and then a variable "$node" and then $2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13 and at the end another string " ; COMMIT;" ... (4 Replies)
Discussion started by: Vaddadi
4 Replies

7. Shell Programming and Scripting

Remove lines between the start string and end string including start and end string Python

Hi, I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

8. Shell Programming and Scripting

Search a string in a text file and add another string at the end of line

Dear All I am having a text file which is having more than 200 lines. EX: 001010122 12000 BIB 12000 11200 1200003 001010122 2000 AND 12000 11200 1200003 001010122 12000 KVB 12000 11200 1200003 In the above file i want to search for string KVB... (5 Replies)
Discussion started by: suryanarayana
5 Replies

9. UNIX for Dummies Questions & Answers

Extracting an ipaddress and using it to send files but error at the end of file

i want to extract ip address from a file and using that ip address copy file to systems. set fid set content close $fid ## Split into records on newlines set records send "records splited\n" send $records\n set timeout 600 set a "test\n" send $a foreach rec $records { ##... (1 Reply)
Discussion started by: amature_rach
1 Replies

10. Shell Programming and Scripting

Extracting substring within string between 2 token within the string

Hello. First best wishes for everybody. here is the input file ("$INPUT1") contents : BASH_FUNC_message_begin_script%%=() { local -a L_ARRAY; BASH_FUNC_message_debug%%=() { local -a L_ARRAY; BASH_FUNC_message_end_script%%=() { local -a L_ARRAY; BASH_FUNC_message_error%%=() { local... (3 Replies)
Discussion started by: jcdole
3 Replies
Tcl_GetIndexFromObj(3)					      Tcl Library Procedures					    Tcl_GetIndexFromObj(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tcl_GetIndexFromObj, Tcl_GetIndexFromObjStruct - lookup string in table of keywords SYNOPSIS
#include <tcl.h> int Tcl_GetIndexFromObj(interp, objPtr, tablePtr, msg, flags, indexPtr) int | Tcl_GetIndexFromObjStruct(interp, objPtr, structTablePtr, offset, | msg, flags, indexPtr) | ARGUMENTS
Tcl_Interp *interp (in) Interpreter to use for error reporting; if NULL, then no message is provided on errors. Tcl_Obj *objPtr (in/out) The string value of this object is used to search through tablePtr. The internal representation is modified to hold the index of the matching table entry. CONST char **tablePtr (in) An array of null-terminated strings. The end of the array is marked by a NULL string pointer. CONST VOID *structTablePtr(in) An array of arbitrary type, typically some struct type. The first member of the structure must be a null-terminated string. The size of the structure is given by offset. | int offset (in) | The offset to add to structTablePtr to get to the next entry. The end of the array is marked by a NULL | string pointer. CONST char *msg (in) Null-terminated string describing what is being looked up, such as option. This string is included in error messages. int flags (in) OR-ed combination of bits providing additional information for operation. The only bit that is cur- rently defined is TCL_EXACT. int *indexPtr (out) The index of the string in tablePtr that matches the value of objPtr is returned here. _________________________________________________________________ DESCRIPTION
This procedure provides an efficient way for looking up keywords, switch names, option names, and similar things where the value of an object must be one of a predefined set of values. ObjPtr is compared against each of the strings in tablePtr to find a match. A match occurs if objPtr's string value is identical to one of the strings in tablePtr, or if it is a unique abbreviation for exactly one of the strings in tablePtr and the TCL_EXACT flag was not specified; in either case the index of the matching entry is stored at *indexPtr and TCL_OK is returned. If there is no matching entry, TCL_ERROR is returned and an error message is left in interp's result if interp isn't NULL. Msg is included in the error message to indicate what was being looked up. For example, if msg is option the error message will have a form like bad option "firt": must be first, second, or third. If Tcl_GetIndexFromObj completes successfully it modifies the internal representation of objPtr to hold the address of the table and the index of the matching entry. If Tcl_GetIndexFromObj is invoked again with the same objPtr and tablePtr arguments (e.g. during a reinvoca- tion of a Tcl command), it returns the matching index immediately without having to redo the lookup operation. Note: Tcl_GetIndexFromObj assumes that the entries in tablePtr are static: they must not change between invocations. If the value of objPtr is the empty string, Tcl_GetIndexFromObj will treat it as a non-matching value and return TCL_ERROR. | Tcl_GetIndexFromObjStruct works just like Tcl_GetIndexFromObj, except that instead of treating tablePtr as an array of string pointers, it | treats it as the first in a series of string ptrs that are spaced apart by offset bytes. This is particularly useful when processing things | like Tk_ConfigurationSpec, whose string keys are in the same place in each of several array elements. SEE ALSO
Tcl_WrongNumArgs KEYWORDS
index, object, table lookup Tcl 8.1 Tcl_GetIndexFromObj(3)
All times are GMT -4. The time now is 07:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy