Sponsored Content
Top Forums Shell Programming and Scripting How to search (grep?) filename for a string and if it contains this then... Post 302259663 by tuathan on Tuesday 18th of November 2008 04:43:50 PM
Old 11-18-2008
How to search (grep?) filename for a string and if it contains this then...

Hi i want to write a script that will search a filename e.g. test06abc.txt for a string and if it contains this string then set a variable equal to something:

something like:

var1=0

search <filename> for 06
if it contains 06 then
var1=1
else
var1=0
end if

but in unix script Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Appending to filename a string of text grep finds

I am wanting to automate a process that includes the step of appending to a filename a string of text that's contained inside the file. I.e. if filename A.fileA contains a string of text that reads 1234 after the phrase ABC, I want the shell script file to rename the file 1234_FileChecked_A.fileA.... (3 Replies)
Discussion started by: HLee1981
3 Replies

2. Shell Programming and Scripting

grep: RE error 41: No remembered search string.

Hi guys, I am currently facing a problem with my current script, the script basically monitor a list of process on the Unix system. If a process is down it will send a notification e-mail to me. Currently I am facing an error when running the script grep: RE error 41: No remembered search... (2 Replies)
Discussion started by: fkaba81
2 Replies

3. Shell Programming and Scripting

grep string and output filename

Hello, I have over 200 files and some of them have the string like "John price $200". I would like to grep the string. Then output the filename which found the string. I have the following script, but it ONLY output the string echo Please input list file name: read listn for file in `cat... (3 Replies)
Discussion started by: happyv
3 Replies

4. UNIX for Dummies Questions & Answers

grep for a search string

Hi, I want to grep one file for a search string and get the next 10 lines after the search string. for eg,in file tnsnames.ora,i have 100 entries.i want to search for one string and get the entry for that db. please help how to acheive this using awk or sed? Thanks. (11 Replies)
Discussion started by: raga
11 Replies

5. Shell Programming and Scripting

Search for string in filename, not file content

How can I search for a string in a filename? For example, I want to know if a filename (not the file contents) contains the string "test". (3 Replies)
Discussion started by: daflore
3 Replies

6. UNIX for Dummies Questions & Answers

How to search for string A OR string B using Grep?

Hi, This is what I have done so far which is wrong for some reason: grep -h "stringA | stringB" filename Thank in advance! (5 Replies)
Discussion started by: jboy
5 Replies

7. Shell Programming and Scripting

grep exact string from files and write to filename when string present in file

I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Discussion started by: JC_1
4 Replies

8. Shell Programming and Scripting

Grep string search

Hi All, I'm using aix flavour unix where im trying for the below kind of pattern to search in all the files in a directory. I tried with different possible combinations like grep -ir "out.*\transaction_ctry_code" * etc.... Pattern I'm trying for : out<any thing>country_cd Here i... (0 Replies)
Discussion started by: rmkganesh
0 Replies

9. Shell Programming and Scripting

How to grep for a string on a FILENAME?

I call my bash shell script "test.sh" and pass "admin_usr.txt" as an argument like below. ./test.sh admin_usr.txt Inside the "test.sh" i wish to check if the filename passed "admin_usr.txt" i.e "$1" contains the string "admin" or not ... which in this case it does. Note: I do not wish to... (5 Replies)
Discussion started by: mohtashims
5 Replies

10. UNIX for Beginners Questions & Answers

How to use a grep search to search for a specific string within multiple directories?

Lets say I have a massive directory which is filled with other directories all filled with different c++ scripts and I want a listing of all the scripts that contain the string: "this string". Is there a way to use a grep search for that? I tried: grep -lr "this string" * but I do not... (3 Replies)
Discussion started by: Circuits
3 Replies
MYSQLI_STMT.BIND_PARAM(3)						 1						 MYSQLI_STMT.BIND_PARAM(3)

mysqli_stmt::bind_param - Binds variables to a prepared statement as parameters

       Object oriented style

SYNOPSIS
bool mysqli_stmt::bind_param (string $types, mixed &$var1, [mixed &$...]) DESCRIPTION
Procedural style bool mysqli_stmt_bind_param (mysqli_stmt $stmt, string $types, mixed &$var1, [mixed &$...]) Bind variables for the parameter markers in the SQL statement that was passed to mysqli_prepare(3). Note If data size of a variable exceeds max. allowed packet size (max_allowed_packet), you have to specify b in $types and use mysqli_stmt_send_long_data(3) to send the data in packets. Note Care must be taken when using mysqli_stmt_bind_param(3) in conjunction with call_user_func_array(3). Note that mysqli_stmt_bind_param(3) requires parameters to be passed by reference, whereas call_user_func_array(3) can accept as a parameter a list of variables that can represent references or values. PARAMETERS
o $ stmt -Procedural style only: A statement identifier returned by mysqli_stmt_init(3). o $types - A string that contains one or more characters which specify the types for the corresponding bind variables: Type specification chars +----------+---------------------------------------------------+ |Character | | | | | | | Description | | | | +----------+---------------------------------------------------+ | i | | | | | | | corresponding variable has type integer | | | | | d | | | | | | | corresponding variable has type double | | | | | s | | | | | | | corresponding variable has type string | | | | | b | | | | | | | corresponding variable is a blob and will be sent | | | in packets | | | | +----------+---------------------------------------------------+ o $var1 - The number of variables and length of string $types must match the parameters in the statement. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Object oriented style <?php $mysqli = new mysqli('localhost', 'my_user', 'my_password', 'world'); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } $stmt = $mysqli->prepare("INSERT INTO CountryLanguage VALUES (?, ?, ?, ?)"); $stmt->bind_param('sssd', $code, $language, $official, $percent); $code = 'DEU'; $language = 'Bavarian'; $official = "F"; $percent = 11.2; /* execute prepared statement */ $stmt->execute(); printf("%d Row inserted. ", $stmt->affected_rows); /* close statement and connection */ $stmt->close(); /* Clean up table CountryLanguage */ $mysqli->query("DELETE FROM CountryLanguage WHERE Language='Bavarian'"); printf("%d Row deleted. ", $mysqli->affected_rows); /* close connection */ $mysqli->close(); ?> Example #2 Procedural style <?php $link = mysqli_connect('localhost', 'my_user', 'my_password', 'world'); /* check connection */ if (!$link) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } $stmt = mysqli_prepare($link, "INSERT INTO CountryLanguage VALUES (?, ?, ?, ?)"); mysqli_stmt_bind_param($stmt, 'sssd', $code, $language, $official, $percent); $code = 'DEU'; $language = 'Bavarian'; $official = "F"; $percent = 11.2; /* execute prepared statement */ mysqli_stmt_execute($stmt); printf("%d Row inserted. ", mysqli_stmt_affected_rows($stmt)); /* close statement and connection */ mysqli_stmt_close($stmt); /* Clean up table CountryLanguage */ mysqli_query($link, "DELETE FROM CountryLanguage WHERE Language='Bavarian'"); printf("%d Row deleted. ", mysqli_affected_rows($link)); /* close connection */ mysqli_close($link); ?> The above examples will output: 1 Row inserted. 1 Row deleted. SEE ALSO
mysqli_stmt_bind_result(3), mysqli_stmt_execute(3), mysqli_stmt_fetch(3), mysqli_prepare(3), mysqli_stmt_send_long_data(3), mysqli_stmt_errno(3), mysqli_stmt_error(3). PHP Documentation Group MYSQLI_STMT.BIND_PARAM(3)
All times are GMT -4. The time now is 05:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy