Sponsored Content
Top Forums Shell Programming and Scripting Search and replace words between two keywords Post 71264 by tmarikle on Monday 9th of May 2005 12:39:10 PM
Old 05-09-2005
No doubt there is a better way but this sure seemed to work for me:
Code:
nawk '
    BEGIN{RS=";"}
    {
        gsub(/[Ff][Rr][Oo][Mm].*[Ww][Hh][Ee][Rr][Ee]/,"where",$0)
        gsub(/\012/,"",$0)
        printf("%s;\n",$0)
    }' yourfilename

My only issue is that there is an extract semicolon at the end of2the output.

Code:
select * where test_id=1;
select id where test_id=1 and test_id=2;
select * where in (select test2_id from test2);
select id1, id2 where test_id=1;
;

Thomas
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to search for keywords in subsequent lines

Hi all, I am looking for a coomand to search for the keywords in susequenct lines. Keyword1 in a line and Keyword2 in the very next line. Once i found the combination ineed to print the lines with patterns and the line above and one below. I am giving an example here: Keywords are :ERROR and... (12 Replies)
Discussion started by: rdhanek
12 Replies

2. Shell Programming and Scripting

Search a file with keywords

Hi All I have a file of format asdf asf first sec endi asdk rt 123 ferf dfg ijglkp (7 Replies)
Discussion started by: mailabdulbari
7 Replies

3. Shell Programming and Scripting

search and replace combination of two words...with a constraint

Hi I have 100 files in my directory. Please help me how to do in Unix or any other scriptin lanuages. I want to replace all occurances of "goutham" to goutham_ind ONLY if the file contains the word "goutham" with the word "engineer"; for eg----test1 is a file contains the following inf; goutham... (6 Replies)
Discussion started by: nandugo1
6 Replies

4. Shell Programming and Scripting

Shell script to find out words, replace them and count words

hello, i 'd like your help about a bash script which: 1. finds inside the html file (it is attached with my post) the code number of the Latest Stable Kernel, 2.finds the link which leads to the download location of the Latest Stable Kernel version, (the right link should lead to the file... (3 Replies)
Discussion started by: alex83
3 Replies

5. Shell Programming and Scripting

Perl - use search keywords from array and search a file and print 3rd field when matched

Hi , I have been trying to write a perl script to do this job. But i am not able to achieve the desired result. Below is my code. my $current_value=12345; my @users=("bob","ben","tom","harry"); open DBLIST,"<","/var/tmp/DBinfo"; my @input = <DBLIST>; foreach (@users) { my... (11 Replies)
Discussion started by: chidori
11 Replies

6. Shell Programming and Scripting

Extracting words and lines based on keywords

Hello! I'm trying to process a text file and am stuck at 2 extractions. Hoping someone can help me here: 1. Given a line in a text file and given a keyword, how can I extract the word preceeding the keyword using a shell command/script? For example: Given a keyword "world" in the line: ... (2 Replies)
Discussion started by: seemad
2 Replies

7. UNIX for Dummies Questions & Answers

Replace the words in the file to the words that user type?

Hello, I would like to change my setting in a file to the setting that user input. For example, by default it is ONBOOT=ON When user key in "YES", it would be ONBOOT=YES -------------- This code only adds in the entire user input, but didn't replace it. How do i go about... (5 Replies)
Discussion started by: malfolozy
5 Replies

8. Shell Programming and Scripting

Search words in any quote position and then change the words

hi, i need to replace all words in any quote position and then need to change the words inside the file thousand of raw. textfile data : "Ninguno","Confirma","JuicioABC" "JuicioCOMP","Recurso","JuicioABC" "JuicioDELL","Nulidad","Nosino" "Solidade","JuicioEUR","Segundo" need... (1 Reply)
Discussion started by: benjietambling
1 Replies

9. Shell Programming and Scripting

Replace particular words in file based on if finds another words in that line

Hi All, I need one help to replace particular words in file based on if finds another words in that file . i.e. my self is peter@king. i am staying at north sydney. we all are peter@king. How to replace peter to sham if it finds @king in any line of that file. Please help me... (8 Replies)
Discussion started by: Rajib Podder
8 Replies
SELECT(9)						   BSD Kernel Developer's Manual						 SELECT(9)

NAME
seldestroy, selinit, selrecord, selnotify -- select and poll subsystem SYNOPSIS
#include <sys/param.h> #include <sys/select.h> void seldestroy(struct selinfo *sip); void selinit(struct selinfo *sip); void selrecord(struct lwp *selector, struct selinfo *sip); void selnotify(struct selinfo *sip, int events, long knhint); DESCRIPTION
selinit() and seldestroy() functions must be used to initialize and destroy the struct selinfo. The seldestroy() function may block. selrecord() and selnotify() are used by device drivers to coordinate with the kernel implementation of select(2) and poll(2). Each object that can be polled contains a selinfo record. Device drivers provide locking for the selinfo record. selrecord() records that the calling thread is interested in events related to a given object. selrecord() should only be called when the poll routine determines that the object is not ready for I/O: there are no events of interest pending. The check for pending I/O and call to selrecord() must be atomic. Atomicity can be provided by holding the object's lock across the test and call to selrecord(). For non-MPSAFE drivers, the global kernel_lock is enough to provide atomicity. selnotify() is called by the underlying object handling code in order to notify any waiting threads that an event of interest has occurred. The same lock held across the poll method and call to selrecord() must be held across the call to selnotify(). The lock prevents an event of interest being signalled while a thread is in the process of recording its interest. The events indicates which event happen. Zero may be used if unknown. selnotify() also calls KNOTE() passing knhint as an argument. CODE REFERENCES
The core of the select and poll subsystem implementation is in sys/kern/sys_select.c. Data structures and function prototypes are located in sys/sys/select.h, sys/sys/poll.h and sys/sys/selinfo.h. SEE ALSO
poll(2), select(2), knote(9) BSD
May 13, 2008 BSD
All times are GMT -4. The time now is 04:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy