Sponsored Content
Top Forums Shell Programming and Scripting How to search (grep?) filename for a string and if it contains this then... Post 302259770 by mailme0712 on Wednesday 19th of November 2008 12:55:31 AM
Old 11-19-2008
using find command followed by if condition

Hi try this

file=`find dirpath -type f -name "filename" -exec grep 06 {} \;`

if [ "$file" = "" ] ; then
var=0
else
var=1
fi

Last edited by mailme0712; 11-19-2008 at 05:04 AM..
 

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
Statistics::Basic::Variance(3pm)			User Contributed Perl Documentation			  Statistics::Basic::Variance(3pm)

NAME
Statistics::Basic::Variance - find the variance of a list SYNOPSIS
Invoke it this way: my $variance = variance(1,2,3); Or this way: my $v1 = vector(1,2,3); my $var = var($v1); And then either query the values or print them like so: print "The variance of $v1: $variance "; my $vq = $var->query; my $v0 = 0+$var; Create a 20 point "moving" variance like so: use Statistics::Basic qw(:all nofill); my $sth = $dbh->prepare("select col1 from data where something"); my $len = 20; my $var = var()->set_size($len); $sth->execute or die $dbh->errstr; $sth->bind_columns( my $val ) or die $dbh->errstr; while( $sth->fetch ) { $var->insert( $val ); if( defined( my $v = $var->query ) ) { print "Variance: $v "; } # This would also work: # print "Variance: $v " if $var->query_filled; } METHODS
new() The constructor takes a list of values, a single array ref, or a single Statistics::Basic::Vector as arguments. It returns a Statistics::Basic::Variance object. Note: normally you'd use the mean() constructor, rather than building these by hand using "new()". query_mean() Returns the Statistics::Basic::Mean object used in the variance computation. _OVB::import() This module also inherits all the overloads and methods from Statistics::Basic::_OneVectorBase. AUTHOR
Paul Miller "<jettero@cpan.org>" I am using this software in my own projects... If you find bugs, please please please let me know. :) Actually, let me know if you find it handy at all. Half the fun of releasing this stuff is knowing that people use it. OVERLOADS
This object is overloaded. It tries to return an appropriate string for the calculation or the value of the computation in numeric context. In boolean context, this object is always true (even when empty). COPYRIGHT
Copyright 2012 Paul Miller -- Licensed under the LGPL SEE ALSO
perl(1), Statistics::Basic, Statistics::Basic::_OneVectorBase, Statistics::Basic::Vector perl v5.14.2 2012-01-23 Statistics::Basic::Variance(3pm)
All times are GMT -4. The time now is 07:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy