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
DEBUG_ZVAL_DUMP(3)							 1							DEBUG_ZVAL_DUMP(3)

debug_zval_dump - Dumps a string representation of an internal zend value to output

SYNOPSIS
void debug_zval_dump (mixed $variable, [mixed $...]) DESCRIPTION
Dumps a string representation of an internal zend value to output. PARAMETERS
o $variable - The variable being evaluated. RETURN VALUES
No value is returned. EXAMPLES
Example #1 debug_zval_dump(3) example <?php $var1 = 'Hello World'; $var2 = ''; $var2 =& $var1; debug_zval_dump(&$var1); ?> The above example will output: &string(11) "Hello World" refcount(3) Note Beware the refcount The refcount value returned by this function is non-obvious in certain circumstances. For example, a developer might expect the above example to indicate a refcount of 2. The third reference is created when actually calling debug_zval_dump(3). This behavior is further compounded when a variable is not passed to debug_zval_dump(3) by reference. To illustrate, consider a slightly modified version of the above example: Example #2 <?php $var1 = 'Hello World'; $var2 = ''; $var2 =& $var1; debug_zval_dump($var1); // not passed by reference, this time ?> The above example will output: string(11) "Hello World" refcount(1) Why refcount(1)? Because a copy of $var1 is being made, when the function is called. This function becomes even more confusing when a variable with a refcount of 1 is passed (by copy/value): Example #3 <?php $var1 = 'Hello World'; debug_zval_dump($var1); ?> The above example will output: string(11) "Hello World" refcount(2) A refcount of 2, here, is extremely non-obvious. Especially considering the above examples. So what's happening? When a variable has a single reference (as did $var1 before it was used as an argument to debug_zval_dump(3)), PHP's engine opti- mizes the manner in which it is passed to a function. Internally, PHP treats $var1 like a reference (in that the refcount is increased for the scope of this function), with the caveat that if the passed reference happens to be written to, a copy is made, but only at the moment of writing. This is known as "copy on write." So, if debug_zval_dump(3) happened to write to its sole parameter (and it doesn't), then a copy would be made. Until then, the parameter remains a reference, causing the refcount to be incremented to 2 for the scope of the function call. SEE ALSO
var_dump(3), debug_backtrace(3), References Explained, References Explained (by Derick Rethans). PHP Documentation Group DEBUG_ZVAL_DUMP(3)
All times are GMT -4. The time now is 10:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy