Sponsored Content
Full Discussion: awk search syntax
Top Forums Shell Programming and Scripting awk search syntax Post 303043218 by migurus on Tuesday 21st of January 2020 01:17:52 PM
Old 01-21-2020
awk search syntax

I need help with understanding awk search feature.


Here I am trying to search by 4th field in this file:


Code:
$ cat xx
471013,A20,asd,100,FEATURE UNKNOWN
171014,A22,sdf,101,FEATURE WITH SUB-ELEMENT
172822,20X,xcv,102,SUB-ELEMENT
101102,22X,asd,103,CODED

When I try the search feature I get nothing:
Code:
$ awk -F, '/$4 ~ "101"/{print}' xx        

$

When I just use IF statement it works as expected:
Code:
$ awk -F, '{ if($4 == 101)print; }' xx
171014,A22,sdf,101,FEATURE WITH SUB-ELEMENT
$

Please help me understand what do I do wrong in using the search // syntax
Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK Syntax errors :/

I recently started as an intern and my manager wanted to see how well I would handle Korn Bourne shell scripting without any prior experience, I have prior programming experience but I keep running into syntax errors with AWK. Please take a look at my simple code and tell me what stupid mistake... (6 Replies)
Discussion started by: yongho
6 Replies

2. Shell Programming and Scripting

Help with Awk Syntax

I have written many awk commands which go in multiple lines. I have this confusion many times. Some time they work if i dont terminate them with "\" but some time error. Some time in "if" statements between if and else if i dont use ";" it gives error but sometimes it doesnt. The below... (4 Replies)
Discussion started by: pinnacle
4 Replies

3. Shell Programming and Scripting

awk syntax help

I don't get correct output when I run this command line: nmap -sP failedhost.com | grep -i failed | awk -F '{print $6}' I basically want it to return 'failedhost.com' but its just showing the output of the nmap scan. (8 Replies)
Discussion started by: streetfighter2
8 Replies

4. Shell Programming and Scripting

AWK syntax

Hi I am trying to understand AWK syntax so I tried this command which gives me the home directory of root awk 'BEGIN { FS = ":"} {if ($1 == "root") print $6 }' /etc/passwd I would know what are the following commands doing. The first one prints all /etc/passwd, second prints nothing. ... (4 Replies)
Discussion started by: wakatana
4 Replies

5. UNIX for Dummies Questions & Answers

awk syntax

Little bit confusing while using awk :confused::confused: In Sed while pattern search we can use "(double quotes) i mean $a=hello $cat file.txt |sed -n "/$a/p"this thing work fine But if i use it in awk it's not working How could i do the substitution of pattern by a variables and the... (1 Reply)
Discussion started by: posix
1 Replies

6. Shell Programming and Scripting

AWK syntax help

i have a ksh code that needs to be written in AWK. can someone please help me here? :( if }" | grep -c "$2") -gt 0 ] ; then print - "found $2 in array ignore" else print - "did not find $2 in array ignore" fi ignore=4ty56r ignore=er45ty . . . ignore=frhtg2 (27 Replies)
Discussion started by: usustarr
27 Replies

7. AIX

Help with syntax using AWK

I have a file which is comma separated and has quotes. I can use this command and awk -F"," '{ if ($4=="01" print $0 }' test.txt But this doesn't fetch me the data.since it has quotes. If the data has no quotes,the above command works fine. In Unix you can skip quote \" but this doesn't work.... (7 Replies)
Discussion started by: ganesnar
7 Replies

8. Shell Programming and Scripting

Syntax error using Awk

more report2.txt how to modify the AWK to print above out put for given n no of inputs using report2.txt file? out put should be (3 Replies)
Discussion started by: kanakaraju
3 Replies

9. Shell Programming and Scripting

awk syntax

Hi I have a bash file which will split a big file to many small files. But I got a syntax error.H="$(head -1 CCC.tped)" awk 'print $0 > $1 ".tped"' CCC.tped for f in $(ls *.tped); do echo "$H\n" "$(cat $f)" >$f; done And -bash-4.1$ bash split awk: print $0 > $1".tped" awk: ^ syntax error... (3 Replies)
Discussion started by: zhshqzyc
3 Replies

10. Shell Programming and Scripting

Help with the awk syntax

Hello Experts: While writing a script to help one of the posts on here, I end up writing a wrong one. I am very much eager to know how this can be corrected. Aim was to not print specified columns - lets say out of 100 fields, need to print all but 5th, 10th, 15th columns. Someone already... (13 Replies)
Discussion started by: juzz4fun
13 Replies
REPORT_EVENT.CONF(5)						 LIBREPORT MANUAL					      REPORT_EVENT.CONF(5)

NAME
report_event.conf - configuration file for libreport. DESCRIPTION
This configuration file specifies which programs should be run when the specified event occurs in problem directory lifetime. It consists of directives and rules. Directives start with a reserved word. Currently, there is only one directive, "include". include FILE This directive causes files which match FILE to be read and parsed as if they are inserted textually where this directive occurs. FILE can use shell pattern metacharacters (*,?,etc) to specify multiple files. Relative paths are interpreted relative to current file. Rule starts with a line with non-space leading character. All subsequent lines which start with space or tab form one rule. Note that separating newline is retained. Rules may be commented out with #. One # is sufficient to comment out even a multi-line rule (no need to comment out every line). Rules specify which programs to run on the problem directory. Each rule may have conditions to be checked before the program is run. Conditions have form VAR=VAL or VAL~=REGEX, where VAR is either word "EVENT" or a name of problem directory element to be checked (for example, "executable", "package", hostname" etc). If all conditions match, the remaining part of the rule (the "program" part) is run in the shell. All shell language constructs are valid. All stdout and stderr output is captured and passed to ABRT and possibly to ABRT's frontends and shown to the user. If the program terminates with nonzero exit code, the event processing is considered unsuccessful and is stopped. Last captured output line, if any, is considered to be the error message indicating the reason of the failure, and may be used by abrt as such. If the program terminates successfully, next rule is read and processed. This process is repeated until the end of this file. Event XML configuration These configuration files provides event meta data. Each file has XML formatting with the following DTD: <!ELEMENT event (name+,description+,requires-items?,exclude-items-by-default?,exclude-items-always?,exclude-binary-items?,include-items-by-default?,minimal-rating?,gui-review-elements?,options?)> <!ELEMENT name (#PCDATA)> <!ATTLIST name xml:lang CDATA #IMPLIED> <!ELEMENT description (#PCDATA)> <!ATTLIST description xml:lang CDATA #IMPLIED> <!ELEMENT requires-items (#PCDATA)> <!ELEMENT exclude-items-by-default (#PCDATA)> <!ELEMENT include-items-by-default (#PCDATA)> <!ELEMENT exclude-items-always (#PCDATA)> <!ELEMENT exclude-binary-items ("yes"|"no")> <!ELEMENT minimal-rating ("0"|"1"|"2"|"3"|"4")> <!ELEMENT gui-review-elements ("yes"|"no")> <!ELEMENT options (option*,advanced-options)> <!ELEMENT advanced-options (option)*> <!ELEMENT option (label+,description+,note-html+,allow-empty?,default-value?)> <!ATTLIST option type (text|bool|password|number|hint-html) #REQUIRED name CDATA #REQUIRED> <!ELEMENT label (#PCDATA)> <!ATTLIST label xml:lang CDATA #IMPLIED> <!ELEMENT note-html (#PCDATA)> <!ATTLIST note-html xml:lang CDATA #IMPLIED> <!ELEMENT allow-empty ("yes"|"no")> <!ELEMENT default-value (#PCDATA)> name User visible name of event description User visible description exclude-items-by-default Comma separated names of excluded problem elements. User can include any of these elements if he wishes it. include-items-by-default Comma separated names of included problem elements. User can exclude any of these elements if he wishes it. exclude-items-always Comma separated names of included problem elements. User cannot include any of these elements. exclude-binary-items If "yes" then all binary problem elements are excluded. User can include them if he wishes it. minimal-rating Minimal backtrace rating required for executing the event. Backtrace rating is a measure of backtrace usability and understandability. With an increasing number of unresolved frames the backtrace rating gets lower values. gui-review-elements If "yes", user must explicitly approve that all included problem elements can be published. If "no", the event is executed automatically. If not provided, "yes" is expected. advanced-options List of options which are hidden in the default view. label Event option label note-html Event option HTML formatted description allow-empty Determines if user can leave the option empty default-value A value which is used by default option:name Name of exported environment variable name. libreport tools communicate through Environment Variables. EXAMPLES
EVENT=post-create analyzer=Python abrt-action-analyze-python EVENT=post-create getent passwd "`cat uid`" | cut -d: -f1 >username SEE ALSO
abrtd(8) AUTHOR
Manual page written by Denys Vlasenko <dvlasenk@redhat.com[1]>. NOTES
1. dvlasenk@redhat.com mailto:dvlasenk@redhat.com LIBREPORT 2.1.11 06/18/2014 REPORT_EVENT.CONF(5)
All times are GMT -4. The time now is 05:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy