Sponsored Content
Top Forums UNIX for Advanced & Expert Users use of variables in awk to search for pattern from a file Post 302576184 by jayan_jay on Thursday 24th of November 2011 02:00:02 AM
Old 11-24-2011
try this ..
Code:
$ v1=hello
$ v2=world
$ nawk "/$v1/,/$v2/" infile
hello
line1
line2
world
$

This User Gave Thanks to jayan_jay For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk pattern search and put in a file

hi I am doing a task that is i have to search for multiple pattern from a file's 9 th column and then redirect it to a new file awk -F, 'BEGIN {OSF=","} { if ($9 == "OTF") print $0}' test1.tsv > test.tsv and the patterns are OST. ODI,MIN LIKE OTF Bit not getting the desired output... (11 Replies)
Discussion started by: pranabrana
11 Replies

2. Shell Programming and Scripting

Awk search for string pattern in delimited file

I've got a semicolon delimited file. I would like to search for fields that match a pattern, and not hardcoded eg "mth". *th=something If the delimited field fulfills this condition, eg. mth=value I would like to print out both key and value for some number comparison. eg. if value > "12"... (5 Replies)
Discussion started by: alienated
5 Replies

3. Shell Programming and Scripting

Awk/Sed: Search Pattern from file and Print

Hi, I want to search for patterns (from a file) in a file and print the line matching the patterns and the line before it. I have to search for 100s of patterns from a file. Any help with AWK or Sed. Thanks! (2 Replies)
Discussion started by: saint2006
2 Replies

4. Shell Programming and Scripting

Text pattern with AWK and variables

How to to pass variable to the below awk command I would like to pass variables to the awk command instead of the constants "a/cc" but I don't know exactly the correct syntax awk '/a/,/cc/' temp1.out file.txt a b s cc g d output a b s (8 Replies)
Discussion started by: ahmedamro
8 Replies

5. Shell Programming and Scripting

Help to search multiple pattern in file with grep/sed/awk

Hello All, I have a file which is having below type of data, Jul 19 2011 | 123456 Jul 19 2011 | 123456 Jul 20 2011 | 123456 Jul 20 2011 | 123456 Here I wanted to grep for date pattern as below, so that it should only grep "Jul 20" OR "Jul ... (9 Replies)
Discussion started by: gr8_usk
9 Replies

6. Shell Programming and Scripting

awk get search pattern from a file.

Here Is a problem I am facing with awk. Query --> I want to search for a string in a file and print next 15 lines below the matched string. 1.We do not have GNU grep so cannot use grep -A or grep -B commands. 2. Instead of passing the search pattern as a string to awk. I want the awk to... (4 Replies)
Discussion started by: togotutor
4 Replies

7. Shell Programming and Scripting

Awk to match a pattern and perform a search after the first pattern

Hello Guyz I have been following this forum for a while and the solutions provided are super useful. I currently have a scenario where i need to search for a pattern and start searching by keeping the first pattern as a baseline ABC DEF LMN EFG HIJ LMN OPQ In the above text i need to... (8 Replies)
Discussion started by: RickCharles
8 Replies

8. Shell Programming and Scripting

awk search/replace specific field, using variables for regexp & subsitution then overwrite file

Hello, I'm trying the solve the following problem. I have a file which I intend to use as a csv called master.csv The columns are separated by commas. I want to change the text on a specific row in either column 3,4,5 or 6 from xxx to yyy depending upon if column 1 matches a specified pattern.... (3 Replies)
Discussion started by: cyphex
3 Replies

9. Shell Programming and Scripting

Search for a pattern in a String file and count the occurance of each pattern

I am trying to search a file for a patterns ERR- in a file and return a count for each of the error reported Input file is a free flowing file without any format example of output ERR-00001=5 .... ERR-01010=10 ..... ERR-99999=10 (4 Replies)
Discussion started by: swayam123
4 Replies

10. UNIX for Beginners Questions & Answers

Grep/awk using a begin search pattern and end search pattern

I have this fileA TEST FILE ABC this file contains ABC; TEST FILE DGHT this file contains DGHT; TEST FILE 123 this file contains ABC, this file contains DEF, this file contains XYZ, this file contains KLM ; I want to have a fileZ that has only (begin search pattern for will be... (2 Replies)
Discussion started by: vbabz
2 Replies
GLOBAL LIBRARY 
STATE(3) SLV2 GLOBAL LIBRARY STATE(3) NAME
Global_library_state - The 'world' represents all library state, and the data found in bundles' manifest.ttl (ie it is an in-memory index of all things LV2 found). Functions SLV2World slv2_world_new () void slv2_world_free (SLV2World world) void slv2_world_load_all (SLV2World world) void slv2_world_load_bundle (SLV2World world, SLV2Value bundle_uri) SLV2PluginClass slv2_world_get_plugin_class (SLV2World world) SLV2PluginClasses slv2_world_get_plugin_classes (SLV2World world) SLV2Plugins slv2_world_get_all_plugins (SLV2World world) SLV2Plugins slv2_world_get_plugins_by_filter (SLV2World world, bool(*include)(SLV2Plugin)) Detailed Description Plugins (and plugin extensions) and the LV2 specification (and LV2 extensions) itself can be queried from the world for use. Normal hosts which just want to easily load plugins by URI are strongly recommended to simply call slv2_world_load_all to find all installed data in the recommended way. Normal hosts should NOT have to refer to bundles directly under normal circumstances. However, functions are provided to load individual bundles explicitly, intended for hosts which depend on a specific bundle (which is shipped with the application). Function Documentation SLV2World slv2_world_new () Initialize a new, empty world. If initialization fails, NULL is returned. SLV2World slv2_world_new_using_rdf_world (librdf_world * world) Initialize a new, empty world, using an existing Redland context. void slv2_world_free (SLV2World world) Destroy the world, mwahaha. NB: Destroying the world will leave dangling references in any plugin lists, plugins, etc. Do not destroy the world until you are finished with all objects that came from it. void slv2_world_load_all (SLV2World world) Load all installed LV2 bundles on the system. This is the recommended way for hosts to load LV2 data. It does the most reasonable thing to find all installed plugins, extensions, etc. on the system. The environment variable LV2_PATH may be used to set the directories inside which this function will look for bundles. Otherwise a sensible, standard default will be used. Use of other functions for loading bundles is highly discouraged without a special reason to do so - use this one. Time = Query void slv2_world_load_bundle (SLV2World world, SLV2Value bundle_uri) Load a specific bundle. o bundle_uri A fully qualified URI to the bundle directory, with the trailing slash, eg. file:///usr/lib/lv2/someBundle/ Normal hosts should not use this function. Hosts should never attach any long-term significance to bundle paths as there are no guarantees they will remain consistent whatsoever. Plugins (and other things) are identified by URIs, not bundle or file names. This function should only be used by apps which ship with a special bundle (which it knows exists at some path because the bundle is shipped with the application). Time = Query SLV2PluginClass slv2_world_get_plugin_class (SLV2World world) Get the parent of all other plugin classes, lv2:Plugin. Time = O(1) SLV2PluginClasses slv2_world_get_plugin_classes (SLV2World world) Return a list of all found plugin classes. Returned list is owned by world and must not be freed by the caller. Time = O(1) SLV2Plugins slv2_world_get_all_plugins (SLV2World world) Return a list of all found plugins. The returned list contains just enough references to query or instantiate plugins. The data for a particular plugin will not be loaded into memory until a call to an slv2_plugin_* function results in a query (at which time the data is cached with the SLV2Plugin so future queries are very fast). Returned list must be freed by user with slv2_plugins_free. The contained plugins are owned by world and must not be freed by caller. Time = O(1) SLV2Plugins slv2_world_get_plugins_by_filter (SLV2World world, bool(*)(SLV2Plugin) include) Return a list of found plugins filtered by a user-defined filter function. All plugins currently found in world that return true when passed to include (a pointer to a function which takes an SLV2Plugin and returns a bool) will be in the returned list. Returned list must be freed by user with slv2_plugins_free. The contained plugins are owned by world and must not be freed by caller. Time = O(n * Time(include)) Author Generated automatically by Doxygen for SLV2 from the source code. Version 0.6.6 2 Apr 2009 GLOBAL LIBRARY STATE(3)
All times are GMT -4. The time now is 09:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy