Sponsored Content
Top Forums Shell Programming and Scripting awk to print specific line in file based on criteria Post 302982037 by cmccabe on Thursday 22nd of September 2016 02:16:50 PM
Old 09-22-2016
awk to print specific line in file based on criteria

In the file below I am trying to extract a specific instance of path, if the adjacent plugin": "/rundb/api/v1/plugin/49/. Thank you Smilie.

file
Code:
"path": "/results/analysis/output/Home/Auto_user_S5-00580-4-Medexome_65_028/plugin_out/FileExporter_out.52", "plugin": "/rundb/api/v1/plugin/49/", "pluginName": "FileExporter", "pluginVersion": "5.0.3.1", "path": "/results/analysis/output/Home/Auto_user_S5-00580-7-Medexome_68_tn_035/plugin_out/variantCaller_out.49", "plugin": "/rundb/api/v1/plugin/41/", "pluginName": "variantCaller", "pluginVersion": "5.0.4.0",

awk
Code:
awk -F"\"[,:]* *\"*" '
        {for (i=1; i<NF; i++)(a=1; a<NF; a++)   {if ($i =="path") and $a =="plugin": /rundb/api/v1/plugin/49/"  print $(i+1)
                                }
        }
' file

desired output
Code:
/results/analysis/output/Home/Auto_user_S5-00580-4-Medexome_65_028/plugin_out/FileExporter_out.52

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To print a specific line in Shell or awk.

Hi, I want to echo the 15th line from a file named as abc.txt, also i want to echo only the values in that line not the line number. Thanks in advance:) (4 Replies)
Discussion started by: tushar_tus
4 Replies

2. Shell Programming and Scripting

Append specific lines to a previous line based on sequential search criteria

I'll try explain this as best I can. Let me know if it is not clear. I have large text files that contain data as such: 143593502 09-08-20 09:02:13 xxxxxxxxxxx xxxxxxxxxxx 09-08-20 09:02:11 N line 1 test line 2 test line 3 test 143593503 09-08-20 09:02:13... (3 Replies)
Discussion started by: jesse
3 Replies

3. Shell Programming and Scripting

Extract data based on specific search criteria

I have a huge file (about 2 millions records) contains data separated by “,” (comma). As part of the requirement, I can't change the format. The objective is to remove some of the records with the following condition. If the 23rd field on each line start with 302 , I need to remove that from the... (4 Replies)
Discussion started by: jaygamini
4 Replies

4. Shell Programming and Scripting

AWK Print Line If Specific Character Is Matched

Hello, I have a file as such: FFFFFFF6C000000 225280 225240 - - rwxs- FFFFFFFF79C00000 3240 3240 - - rwxs- FFFFFFFF7A000000 4096 4096 - - rwxs- FFFFFFFF7A400000 64 64 ... (3 Replies)
Discussion started by: PointyWombat
3 Replies

5. Shell Programming and Scripting

Passing parameter in sed or awk commands to print for the specific line in a file

Hi, I am trying to print a specific line in a file through sed or awk. The line number will be passed as a parameter from the previous step. My code looks as below. TEMP3=`sed -n '$TEMP2p' $FILEPATH/Log.txt` $TEMP2, I am getting from the previous step which is a numerical value(eg:3). ... (2 Replies)
Discussion started by: satyasrin82
2 Replies

6. Shell Programming and Scripting

Extract error records based on specific criteria from Unix file

Hi, I look for a awk one liner for below issue. input file ABC 1234 abc 12345 ABC 4567 678 XYZ xyz ght 678 ABC 787 yyuu ABC 789 7890 777 zxr hyip hyu mno uii 678 776 ABC ty7 888 All lines should be started with ABC as first field. If a record has another value for 1st... (7 Replies)
Discussion started by: ratheesh2011
7 Replies

7. Shell Programming and Scripting

Only print specific xml values that meet two criteria in python

I have a large XML file that I want to parse, and only print one specific value if two values are met. This is the code so far: #!/usr/local/bin/python import xml.etree.ElementTree as ET tree = ET.parse('onedb-dhcp.xml') root = tree.getroot() # This successfully gets all... (1 Reply)
Discussion started by: brianjb
1 Replies

8. Shell Programming and Scripting

Need a Linux command for find/replace column based on specific criteria.

I'm new to shell programming, I have a huge text file in the following format, where columns are separated by single space: ACA MEX 4O_ $98.00 $127.40 $166.60 0:00 0:00 0 ; ACA YUL TS_ $300.00 $390.00 $510.00 0:00 0:00 0 ; ACA YYZ TS_ $300.00 $390.00 $510.00 0:00 0:00 0 ; ADZ YUL TS_ $300.00... (3 Replies)
Discussion started by: transat
3 Replies

9. Shell Programming and Scripting

awk to print line based on two keywords

I am starting to write a multi-line awk and using the file below which is tab-delimited, print only the line with oncomineGeneClass and oncomineVariantClass and PASS. The script execute but seems to be printing the entire file, not the desired line. Thank you :). file ... (8 Replies)
Discussion started by: cmccabe
8 Replies

10. Shell Programming and Scripting

Awk/sed/cut to filter out records from a file based on criteria

I have two files and would need to filter out records based on certain criteria, these column are of variable lengths, but the lengths are uniform throughout all the records of the file. I have shown a sample of three records below. Line 1-9 is the item number "0227546_1" in the case of the first... (15 Replies)
Discussion started by: MIA651
15 Replies
Munin::Node::Configure::Plugin(3pm)			User Contributed Perl Documentation		       Munin::Node::Configure::Plugin(3pm)

NAME
Munin::Node::Configure::Plugin - Class representing a plugin, along with its installed and suggested services. SYNOPSIS
my $plugin = Munin::Node::Configure::Plugin->new(); METHODS
new(%args) Constructor. Required arguments are 'name' and 'path', which should be the basename and full path of the plugin, respectively. is_wildcard() Returns true if the plugin is a wildcard. In the case of SNMP plugins, only double-wild plugins will return true (ie. 'snmp__memory' would return false, but 'snmp__if_' would return true). is_snmp() Returns true if the plugin is an SNMP plugin. in_family(@families) Returns true if plugin's family is in @families, false otherwise. is_installed() Returns 'yes' if one or more links to this plugin exist in the service directory, 'no' otherwise. suggestion_string() Returns a string detailing whether or not autoconf considers that the plugin should be installed. The string may also report the reason why the plugin declined to be installed, or the list of suggestions it provided, if this information is available. installed_services_string() Returns a string detailing which wildcards are installed for this plugin. services_to_add() services_to_remove() Return a list of service names that should be added or removed for this plugin. add_instance($name) Associates a link from the service directory with this plugin. add_suggestions(@suggestions) Adds @suggestions to the list of suggested wildcards for this plugin. They are not validated. read_magic_markers() Sets the family and capabilities from the magic markers embedded in the plugin's executable, as specified by http://munin-monitoring.org/wiki/ConcisePlugins#Magicmarkers <http://munin-monitoring.org/wiki/ConcisePlugins#Magicmarkers> parse_autoconf_response(@response) Parses and validates the autoconf response from the plugin, in the format specified by http://munin-monitoring.org/wiki/ConcisePlugins#autoconf <http://munin-monitoring.org/wiki/ConcisePlugins#autoconf> Invalid input will cause an error to be logged against the plugin. parse_suggest_response(@response) Validates the suggestions from the plugin. Invalid suggestions will cause an error to be logged against the plugin. parse_snmpconf_response(@response) Parses and validates the snmpconf response from the plugin, in the format specified by http://munin-monitoring.org/wiki/ConcisePlugins#suggest <http://munin-monitoring.org/wiki/ConcisePlugins#suggest> Invalid or inconsistent input will cause an error to be logged against the plugin. log_error($message) Logs an error for later retrieval. The error will also be displayed if debugging output is enabled. perl v5.14.2 2013-11-12 Munin::Node::Configure::Plugin(3pm)
All times are GMT -4. The time now is 04:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy