05-05-2004
I think that your problem is that you are using find to grep on the ./logs directory itself and not just on the files in that directory. You need to restrict the find to only grep within plain files.
Lets test this theory, using some test files...
$ mkdir logs
$ echo 'Process Complete' > logs/log1
$ echo 'otherwise' > logs/log2
...first find files that do contain the string...
$ find ./logs -size +1c -exec grep -q 'Process Complete' {} \; -print
./logs/log1
...as expected. Now find files that do NOT contain the string...
$ find ./logs -size +1c ! -exec grep -q 'Process Complete' {} \; -print
./logs
./logs/log2
...woah! What's that "./logs" thing doing there?! If I was using "-exec ls -l {} \;" then it would return every file in the directory! Better restrict the find to plain files...
$ find ./logs -type f -size +1c ! -exec grep -q 'Process Complete' {} \; -print
./logs/log2
...OK!
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi Friends,
How can I search all files in all slices on a unix system for a particular string within the file.
e.g search string 'oracle'
Thanks (4 Replies)
Discussion started by: sureshy
4 Replies
2. Shell Programming and Scripting
I just want to know where I can download it on this website plz (1 Reply)
Discussion started by: memattmyself
1 Replies
3. UNIX for Dummies Questions & Answers
I'm looking to seach all the files in a directory and sub-directories looking for a string. When the string is found, I want to display the filename and the entire line of that file that the string was found on.
what is the best way to do this ?? I've been playing around with awk, find, and... (15 Replies)
Discussion started by: 35Soinc
15 Replies
4. UNIX for Dummies Questions & Answers
I have many scripts in directories and sub-directories that I would like to search for a specific string. How would I do that? (1 Reply)
Discussion started by: bggibson
1 Replies
5. Shell Programming and Scripting
I'm trying to remove the following string from several files.
<img heigth="1" width="1" border="0" src="http://myteenmovies.net/t.php?id=5540372">I'm using the following script
#!/bin/bash
# This script will search and replace all regular files for a string
# supplied by the user and... (1 Reply)
Discussion started by: d13g0sv
1 Replies
6. Shell Programming and Scripting
Hi,
Basically i want to search for a string in file two based on the input file one and if it matches get the nextline and print the value of the field name.
cat one
abc
xyz
defcat two
<src>
<name="path/to/abc" test="value_version">
<new name="Y2" >
</src>
<src>
<name="path/to/xyz"... (5 Replies)
Discussion started by: greet_sed
5 Replies
7. Shell Programming and Scripting
I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios.
Cat test
Nov 10, 2012 5:17:53 AM
INFO: Request Type
Line 1.... (5 Replies)
Discussion started by: laknar
5 Replies
8. UNIX for Advanced & Expert Users
i have a file named keyword.csv(contains around 8k records) which contains a no. of columns.
The 5th column contains all the keywords.
I want to recursively search these keywords in all .pl files(around 1k) and display the filename....Afterthat i will use the filename and some of the column from... (3 Replies)
Discussion started by: millan
3 Replies
9. Shell Programming and Scripting
Hi,
Need your help for this scripting issue I have. I am not really good at this, so seeking your help.
I have a file looking similar to this:
Hello, i am human and name=ABCD.
How are you?
Hello, i am human and name=PQRS.
I am good.
Hello, i am human and name=ABCD.
Good bye.
Hello, i... (12 Replies)
Discussion started by: royzlife
12 Replies
10. UNIX for Beginners Questions & Answers
I have 13 text files and almost all of them contain the same string.
but some file has diffrent string inside.
I want to send that file which has a diffrent string inside (11 Replies)
Discussion started by: Sagar Singh
11 Replies
LEARN ABOUT OPENSOLARIS
gnome-search-tool
gnome-search-tool(1) User Commands gnome-search-tool(1)
NAME
gnome-search-tool - search for files
SYNOPSIS
gnome-search-tool [--named=text] [--path=folder] [--sortby=order] [--descending] [--contains=string] [--user=user] [--nouser] [--allmounts]
[--empty] [--follow] [--group=group] [--hidden] [--mtimeless=date] [--mtimemore=date] [--notnamed=filename] [--regex=pattern] [--size-
less=size] [--sizemore=size] [--start] [gnome-std-options]
DESCRIPTION
The Search for Files application enables you to search for files on your system. Search for Files uses the find(1) command.
OPTIONS
The following options are supported:
--allmounts Select the 'Search other filesystems' search constraint.
--contains=string Select the 'Contains the text' search constraint and set the text of that entry. Use a full filename or a partial
filename with wildcards. See find(1) for more details about using wildcards.
--descending Set sort order to descending. The default sort order is ascending.
--empty Select the 'File is empty' search constraint.
--follow Select the 'Follow symbolic links' search constraint.
--group=group Select the 'Owned by group' search constraint and set the text of that entry.
--hidden Select the 'Show hidden and backup files' search option.
--mtimeless=date Select the 'Date modified before (days)' search constraint and set the text of that entry.
--mtimemore=date Select the 'Date modified after (days)' search constraint and set the text of that entry.
--named=text Set the text of the 'Name contains' search option.
--notnamed=filename Select the 'File is not named' search constraint and set the text of that entry. Use a full filename or a partial
filename with wildcards. See find(1) for more details about using wildcards.
--nouser Select the 'Owner is unrecognized' search constraint.
--path=folder Set the text of the 'Look in folder' entry. Defaults to the current working directory.
--start Automatically start a search.
--regex=pattern Select the 'File matches regular expression' search constraint and set the text of that entry. See find(1) for more
details about the regular expression patterns that can be used.
--sizeless=size Select the 'Size is less than (kilobytes)' search constraint and set the text of that entry.
--sizemore=size Select the 'Size is more than (kilobytes)' search constraint and set the text of that entry.
--sortby=order Sort files by one of the following: name, folder, size, type, or date.
--user=user Select the 'Owned by user' search constraint and set the text of that entry.
gnome-std-options Standard options available for use with most GNOME applications. See gnome-std-options(5) for more information.
EXAMPLES
Example 1: Performing a basic search automatically
example% gnome-search-tool --name=a.out --path=$HOME --autostart
Example 2: Performing an advanced search automatically
example% gnome-search-tool --contains=unistd.h --mtimeless=3 --sortby=size --autostart
EXIT STATUS
The following exit values are returned:
0 Application exited successfully
>0 Application exited with failure
FILES
The following files are used by this application:
/usr/bin/gnome-search-tool Executable for Search for Files
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWgnome-search-tool |
+-----------------------------+-----------------------------+
|Interface stability |Volatile |
+-----------------------------+-----------------------------+
SEE ALSO
Search for Files Manual
Latest version of the GNOME Desktop User Guide for your platform.
find(1), gnome-std-options(5)
NOTES
Written by Glynn Foster, Sun Microsystems Inc., 2003, 2006.
SunOS 5.11 2 Oct 2003 gnome-search-tool(1)