Sponsored Content
Top Forums Shell Programming and Scripting Recursive search on pattern between two strings Post 302606121 by krishmaths on Friday 9th of March 2012 03:15:01 PM
Old 03-09-2012
Recursive search on pattern between two strings

Objective:
Recursively search all files under a directory for SQL statements that end with ";"

Sample input:
Code:
UPDATE table1
set col=val
UPDATE table2
set cola=vala
,colb=valb;
UPDATE table3
set col=val

Expected output:
Code:
UPDATE table2
set cola=vala
,colb=valb;

as this is the only SQL statement ending with ";"

I tried below code for one file
Code:
awk '/UPDATE/,/;/'  tempfile

but it returned all the lines from the input file.

Please suggest.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

non recursive search in the current directory only

Hi, Am trying for a script which should delete more than 15 days older files in my current directory.Am using the below piece of code: "find /tmp -type f -name "pattern" -mtime +15 -exec /usr/bin/ls -altr {} \;" "find /tmp -type f -name "pattern" -mtime +15 -exec /usr/bin/rm -f {} \;" ... (9 Replies)
Discussion started by: puppala
9 Replies

2. Shell Programming and Scripting

search a pattern and if pattern found insert new pattern at the begining

I am trying to do some thing like this .. In a file , if pattern found insert new pattern at the begining of the line containing the pattern. example: in a file I have this. gtrow0unit1/gctunit_crrownorth_stage5_outnet_feedthru_pin if i find feedthru_pin want to insert !! at the... (7 Replies)
Discussion started by: pitagi
7 Replies

3. Shell Programming and Scripting

Wget recursive with query strings

I am recursively downloading the archive of our emaillist provider with wget, as our provider is shutting down the listserver soon. The list is located at https://listserv.surfnet.nl/archives/umpm-bulletin.html Now I cant make wget save the query-string part of the url, for example... (1 Reply)
Discussion started by: eiland
1 Replies

4. UNIX for Dummies Questions & Answers

recursive search and ftp

Could someone help me in recursive search and ftp'ing the files to remote server? The host machine will have /dir1/dira/list_of_files1 /dir1/dirb/list_of_files2 /dir1/dirc/list_of_files3 . . . so., I need to search from dir1 recursively (only one level down) and find all the files that... (1 Reply)
Discussion started by: brahmi
1 Replies

5. UNIX for Advanced & Expert Users

Recursive directory search using ls instead of find

I was working on a shell script and found that the find command took too long, especially when I had to execute it multiple times. After some thought and research I came up with two functions. fileScan() filescan will cd into a directory and perform any operations you would like from within... (8 Replies)
Discussion started by: newreverie
8 Replies

6. UNIX for Advanced & Expert Users

Recursive search for filenames containing ..

Hi all, Since my gopher server doesn't like filenames containing 2 or more consecutive dots in a filename, I'd like to do a search for them and replace them with... well, let's say underscores... I've tried a oneliner or 2 from other posts, but they don't seem to work well with locating dots.... (3 Replies)
Discussion started by: Evert
3 Replies

7. Shell Programming and Scripting

recursive search and copy

Hello again. Well, I need help again sooner as I thought. Now I want to search for files with a known name within all subdirs, and copy the to differently named files in the same directory. For example if I had only one file to copy, I would just usecp fileName newFileNamebut to do this... (1 Reply)
Discussion started by: cabaciucia
1 Replies

8. Shell Programming and Scripting

awk to search similar strings and arrange in a specified pattern

Hi, I'm running a DB query which returns names of people and writes it in a text file as shown below: Carey, Jim; Cena, John Cena, John Sen, Tim; Burt, Terrence Lock, Jessey; Carey, Jim Norris, Chuck; Lee, Bruce Rock, Dwayne; Lee, Bruce I want to use awk and get all the names... (9 Replies)
Discussion started by: prashu_g
9 Replies

9. OS X (Apple)

Search recursive

before posting, I have tried to find my answer elsewhere. no luck. I need to find a file buried in a folder somewhere. Master folder has 10 sub folders. each sub folder has folders too. I found this but it does nothing I am on Mac and use Applescript. do shell script "find... (2 Replies)
Discussion started by: sbrady
2 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
CUBRID_AFFECTED_ROWS(3) 						 1						   CUBRID_AFFECTED_ROWS(3)

cubrid_affected_rows - Return the number of rows affected by the last SQL statement

SYNOPSIS
int cubrid_affected_rows ([resource $conn_identifier]) DESCRIPTION
int cubrid_affected_rows ([resource $req_identifier]) The cubrid_affected_rows(3) function is used to get the number of rows affected by the SQL statement (INSERT, DELETE, UPDATE). PARAMETERS
o $conn_identifier -The CUBRID connection. If the connection identifier is not specified, the last link opend by cubrid_connect(3) is assumed. o $req_identifier - Request Identifier, could be returned from either cubrid_prepare(3) or cubrid_execute(3). If the request identifier is not spec- ified, the last identifier requested by cubrid_prepare(3) or cubrid_execute(3) is assumed. RETURN VALUES
Number of rows affected by the SQL statement, when process is successful. -1, when SQL statement is not INSERT, DELETE or UPDATE. FALSE, when the request identifier is not specified, and there is no last request. EXAMPLES
Example #1 cubrid_affected_rows(3) example <?php $conn = cubrid_connect('localhost', 33000, 'demodb', 'dba', ''); cubrid_execute($conn, "DROP TABLE IF EXISTS cubrid_test"); cubrid_execute($conn, "CREATE TABLE cubrid_test (d varchar)"); $sql_stmt = "INSERT INTO cubrid_test(d) VALUES('php-test')"; $req = cubrid_prepare($conn, $sql_stmt); for ($i = 0; $i < 10; $i++) { cubrid_execute($req); } cubrid_commit($conn); $req = cubrid_execute($conn, "DELETE FROM cubrid_test WHERE d='php-test'", CUBRID_ASYNC); var_dump(cubrid_affected_rows()); var_dump(cubrid_affected_rows($conn)); var_dump(cubrid_affected_rows($req)); cubrid_disconnect($conn); print "done!"; ?> The above example will output: Rows deleted: 5 SEE ALSO
cubrid_execute(3). PHP Documentation Group CUBRID_AFFECTED_ROWS(3)
All times are GMT -4. The time now is 08:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy