Sponsored Content
Top Forums Shell Programming and Scripting Print matching field using awk Post 302338824 by panyam on Wednesday 29th of July 2009 03:39:33 AM
Old 07-29-2009
Code:
sed "s/.*$val=\([^ \'\" ]*\).*/\1/"


/.*$val=\([^ \'\" ]*\).*/ -> search for the value contained in "val" followed by non space and non single quote and non double quote characters .( using grouping \(.*\) ) , print the same using \1.

You can go through :

Sed - An Introduction and Tutorial
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

[awk] print from field n to field x

Hi, I'm trying to print every line from first field to the fourth from a file containing more. $ cat input a b c d e f g a b c d e f gI'm trying awk '{for (i=1; i <= NF-3; i++) print $i}' awkTest.datbut it printsa b c d a b c dSo, I easily guess I'm wrong. :) Of course, I want:a b... (5 Replies)
Discussion started by: daPeach
5 Replies

2. Shell Programming and Scripting

AWK : Add Fields of lines with matching field

Dear All, I would like to add values of a field, if the lines match in a certain field. Then I would like to divide the sum though the number of lines that have a matched field. This is the Input: Input: Test1 5 Test1 10 Test2 2 Test2 5 Test2 13 Test3 4 Output: Test1 7.5 Test1 7.5... (6 Replies)
Discussion started by: DerSeb
6 Replies

3. Shell Programming and Scripting

Printing entire field, if at least one row is matching by AWK

Dear all, I have been trying to print an entire field, if the first line of the field is matching. For example, my input looks something like this. aaa ddd zzz 123 987 126 24 0.650 985 354 9864 0.32 0.333 4324 000 I am looking for a pattern,... (5 Replies)
Discussion started by: Chulamakuri
5 Replies

4. Shell Programming and Scripting

awk help - matching a field with certail values

Hello there, I have a file with few fields separated by ":". I wrote a below awk to manipulate this file: awk 'BEGIN { FS=OFS=":" }\ NR != 1 && $2 !~ /^98/ && $8 !~ /^6/{print $0}' $in_file > $out_file What I wanted was that if $8 field contains any of the values - 6100, 6110, 6200 -... (2 Replies)
Discussion started by: juzz4fun
2 Replies

5. Shell Programming and Scripting

awk to combine all matching fields in input but only print line with largest value in specific field

In the below I am trying to use awk to match all the $13 values in input, which is tab-delimited, that are in $1 of gene which is just a single column of text. However only the line with the greatest $9 value in input needs to be printed. So in the example below all the MECP2 and LTBP1... (0 Replies)
Discussion started by: cmccabe
0 Replies

6. Shell Programming and Scripting

awk to print array that occurs the most with matching value in another field

In the below awk I am splitting $7 on the : and then counting each line or NM_xxxx. If the $1 value is the same for each line then print the $7 that occurs the most with the matching $1 value. The awk seems close but I am not sure what is going on. I included a description as well as to what I... (1 Reply)
Discussion started by: cmccabe
1 Replies

7. Shell Programming and Scripting

awk to update field using matching value in file1 and substring in field in file2

In the awk below I am trying to set/update the value of $14 in file2 in bold, using the matching NM_ in $12 or $9 in file2 with the NM_ in $2 of file1. The lengths of $9 and $12 can be variable but what is consistent is the start pattern will always be NM_ and the end pattern is always ;... (2 Replies)
Discussion started by: cmccabe
2 Replies

8. Shell Programming and Scripting

awk to add text to matching pattern in field

In the awk I am trying to add :p.=? to the end of each $9 that matches the pattern NM_. The below executes andis close but I can not seem to figure out why the :p.=? repeats in the split as in the green in the current output. I have added comments as well. Thank you :). file ... (4 Replies)
Discussion started by: cmccabe
4 Replies

9. Shell Programming and Scripting

Using awk to add length of matching characters between field in file

The awk below produces the current output, which will add +1 to $3. However, I am trying to add the length of the matching characters between $5 and $6 to $3. I have tried using sub as a variable to store the length but am not able to do so correctly. I added comments to each line and the... (4 Replies)
Discussion started by: cmccabe
4 Replies

10. Shell Programming and Scripting

awk to average field if matching string in another

In the awk below I am trying to get the average of the sum of $7 if the string in $4 matches in the line below it. The --- in the desired out is not needed, it is just to illustrate the calculation. The awk executes and produces the current out. I am not sure why the middle line is skipped and the... (2 Replies)
Discussion started by: cmccabe
2 Replies
XtPopup(3)							   XT FUNCTIONS 							XtPopup(3)

NAME
XtPopup, XtPopupSpringLoaded, XtCallbackNone, XtCallbackNonexclusive, XtCallbackExclusive - map a pop-up SYNTAX
void XtPopup(Widget popup_shell, XtGrabKind grab_kind); void XtPopupSpringLoaded(Widget popup_shell); void XtCallbackNone(Widget w, XtPointer client_data, XtPointer call_data): void XtCallbackNonexclusive(Widget w, XtPointer client_data, XtPointer call_data); void XtCallbackExclusive(Widget w, XtPointer client_data, XtPointer call_data); void MenuPopup(String shell_name); ARGUMENTS
call_data Specifies the callback data, which is not used by this procedure. client_data Specifies the pop-up shell. grab_kind Specifies the way in which user events should be constrained. popup_shell Specifies the widget shell. w Specifies the widget. DESCRIPTION
The XtPopup function performs the following: o Calls XtCheckSubclass to ensure popup_shell is a subclass of Shell. o Generates an error if the shell's popped_up field is already True. o Calls the callback procedures on the shell's popup_callback list. o Sets the shell popped_up field to True, the shell spring_loaded field to False, and the shell grab_kind field from grab_kind. o If the shell's create_popup_child field is non-NULL, XtPopup calls it with popup_shell as the parameter. o If grab_kind is either XtGrabNonexclusive or XtGrabExclusive, it calls: XtAddGrab(popup_shell, (grab_kind == XtGrabExclusive), False) o Calls XtRealizeWidget with popup_shell specified. o Calls XMapWindow with popup_shell specified. The XtPopupSpringLoaded function performs exactly as XtPopup except that it sets the shell spring_loaded field to True and always calls XtAddGrab with exclusive True and spring_loaded True. The XtCallbackNone, XtCallbackNonexclusive, and XtCallbackExclusive functions call XtPopup with the shell specified by the client data argument and grab_kind set as the name specifies. XtCallbackNone, XtCallbackNonexclusive, and XtCallbackExclusive specify XtGrabNone, XtGrabNonexclusive, and XtGrabExclusive, respectively. Each function then sets the widget that executed the callback list to be insensi- tive by using XtSetSensitive. Using these functions in callbacks is not required. In particular, an application must provide customized code for callbacks that create pop-up shells dynamically or that must do more than desensitizing the button. MenuPopup is known to the translation manager, which must perform special actions for spring-loaded pop-ups. Calls to MenuPopup in a translation specification are mapped into calls to a nonexported action procedure, and the translation manager fills in parameters based on the event specified on the left-hand side of a translation. If MenuPopup is invoked on ButtonPress (possibly with modifiers), the translation manager pops up the shell with grab_kind set to XtGrabEx- clusive and spring_loaded set to True. If MenuPopup is invoked on EnterWindow (possibly with modifiers), the translation manager pops up the shell with grab_kind set to XtGrabNonexclusive and spring_loaded set to False. Otherwise, the translation manager generates an error. When the widget is popped up, the following actions occur: o Calls XtCheckSubclass to ensure popup_shell is a subclass of Shell. o Generates an error if the shell's popped_up field is already True. o Calls the callback procedures on the shell's popup_callback list. o Sets the shell popped_up field to True and the shell grab_kind and spring_loaded fields appropriately. o If the shell's create_popup_child field is non-NULL, it is called with popup_shell as the parameter. o Calls: XtAddGrab(popup_shell, (grab_kind == XtGrabExclusive), spring_loaded) o Calls XtRealizeWidget with popup_shell specified. o Calls XMapWindow with popup_shell specified. (Note that these actions are the same as those for XtPopup.) MenuPopup tries to find the shell by searching the widget tree starting at the parent of the widget in which it is invoked. If it finds a shell with the specified name in the pop-up children of that parent, it pops up the shell with the appropriate parameters. Otherwise, it moves up the parent chain as needed. If MenuPopup gets to the applica- tion widget and cannot find a matching shell, it generates an error. SEE ALSO
XtCreatePopupShell(3), XtPopdown(3) X Toolkit Intrinsics - C Language Interface Xlib - C Language X Interface X Version 11 libXt 1.1.3 XtPopup(3)
All times are GMT -4. The time now is 05:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy