Find command don't output anything, but file is there

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find command don't output anything, but file is there
# 1  
Old 02-06-2014
Find command don't output anything, but file is there

Please if You can help me debug why nothing is found by this command?

[root@hostname cron.hourly]# echo "Zeus Robot" >> /home/vps/190/test
[root@hostname cron.hourly]# cat /home/vps/190/test
Zeus Robot
[root@hostname cron.hourly]# find /home/vps -type f -mtime 2 -size -1000k -exec grep -l "Zeus Robot" {} \; >> out
[root@hostname cron.hourly]# cat out
[root@hostname cron.hourly]# cat /home/vps/190/test
Zeus Robot

Why that FIND command did not outputted anything while there is "test" file with that content?
# 2  
Old 02-06-2014
Because the file /home/vps/190/test was only just created and not two days old like mtime specifies.
This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 02-06-2014
You probably meant -mtime -2, for modified in the last 2 days
This User Gave Thanks to Chubler_XL For This Post:
# 4  
Old 02-06-2014
actually i need to find files that are 2 hours and younger... 8-I
# 5  
Old 02-06-2014
Then you want -mmin -120
This User Gave Thanks to Chubler_XL For This Post:
# 6  
Old 02-06-2014
Thank you for helping me point me to wrong -mtime argument. It appears to be solved

---------- Post updated at 10:26 AM ---------- Previous update was at 09:45 AM ----------

there is strange thing..

This script:
find $wheretosearch -type f -mmin -90 -size -1200k -iname '*.php' -o -iname '*.js' -exec grep -l "$phrasse" {} \; >> $outputfile

found me this file:
# stat injection_graph_func.js
  File: `injection_graph_func.js'
  Size: 14500           Blocks: 32         IO Block: 4096   regular file
Device: 903h/2307d      Inode: 111126778   Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2014-02-06 10:01:13.000000000 +0100
Modify: 2011-07-26 10:27:50.000000000 +0200
Change: 2013-11-21 14:29:51.000000000 +0100

as You can see, file dont match my command, i thought "-mmin -90" will search only files modiffied/created last 90 minutes, but above mentioned file appears to be there for much longer time?

Last edited by Scrutinizer; 02-06-2014 at 07:32 AM.. Reason: code tags
# 7  
Old 02-06-2014
The trouble is with -o, the effect of which in this case is that *.php files have this restriction, but *.js files don't. You would need to use additional grouping operators \( and \)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How do I redirect output from "find", either to a file or another command?

I'm trying to find out what happened to the rogue game that apt-get told me it installed, so I thought I would find the file. I went to the root and entered: find -name "rog*.*" I get a large number of lines saying my access is denied in various directories. I figure I'll practice my Unix... (14 Replies)
Discussion started by: arghvark
14 Replies

2. UNIX for Beginners Questions & Answers

Don't have tree, need advise to differentiate dir from file from this alternative that uses find

Hi, I don't have tree on the Solaris server and our SA don't want to install it. I found this example from One Line Linux Command to Print Out Directory Tree Listing | systemBash that more or less does what I am mainly looking for. Example run is as below: $: find ./ | sed -e... (2 Replies)
Discussion started by: newbie_01
2 Replies

3. Shell Programming and Scripting

Insert title as output of command to appended file if no output from command

I am using UNIX to create a script on our system. I have setup my commands to append their output to an outage file. However, some of the commands return no output and so I would like something to take their place. What I need The following command is placed at the prompt: TICLI... (4 Replies)
Discussion started by: jbrass
4 Replies

4. Shell Programming and Scripting

Better Align--output of find command

Hi, i have sh program which search for a file in a folder structure and provides its path. This is just used to see if that file exits more that once anywhere down the folder structure. I have used find command to search & printing it output on terminal. I have attached screen shot of it.... (10 Replies)
Discussion started by: praveenkumar198
10 Replies

5. Shell Programming and Scripting

Help with Passing the Output of grep to sed command - to find and replace a string in a file.

I have a file example.txt as follows :SomeTextGoesHere $$TODAY_DT=20140818 $$TODAY_DT=20140818 $$TODAY_DT=20140818I need to automatically update the date (20140818) in the above file, by getting the new date as argument, using a shell script. (It would even be better if I could pass... (5 Replies)
Discussion started by: SriRamKrish
5 Replies

6. UNIX for Advanced & Expert Users

Don't find file from foxbase 2.1.2d

Hi there, finally i'm installed Sco Foxbase 2.1.2d over my Sco Open Server 5.0.7v server. Well at this point almost is working fine, but, when i Run mi application i receive the next error: "sh: the_name_of_file": does not exist". I checked it over the Hard Disk and the file exist, the... (1 Reply)
Discussion started by: danilosevilla
1 Replies

7. Shell Programming and Scripting

Find zero byte file but don't need path

Just i want to ask How to search and display name of zero byte file I have used find command but it is showing complete file path Thanks find . -size 0 giving me zero byte file with location 1)/home/user/a (4 Replies)
Discussion started by: vivek1489
4 Replies

8. Windows & DOS: Issues & Discussions

Output Of FIND command in dos to Excel File.

Hi I want to export DOS output of find command in Excel. However I want information to be in different column and not in same. I am using this command set /p String_to_search='Enter String to search !' set /p File_to_search='Enter File to search !' findstr /N "%String_to_search%"... (0 Replies)
Discussion started by: dashing201
0 Replies

9. UNIX for Dummies Questions & Answers

problem with output of find command being input to basename command...

Hi, I am triying to make sure that there exists only one file with the pattern abc* in path /path/. This directory is having many huge files. If there is only one file then I have to take its complete name only to use furter in my script. I am planning to do like this: if ; then... (2 Replies)
Discussion started by: new_learner
2 Replies

10. UNIX for Dummies Questions & Answers

output of find command

Hi, I am confused about the output of find command. Please see the two find commands below. When i put "*.c" i get lots of files. But when i put *c only i get only one file. Any answer?? $ find . -name "*c" ./clarify/cheval/hp_server/rulemanager/rulemansvc... (3 Replies)
Discussion started by: shriashishpatil
3 Replies
Login or Register to Ask a Question