Unix/Linux Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Find a file modified yesterday and print it!

UNIX for Dummies Questions & Answers


Tags
mtime

Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-27-2008
Ariean Ariean is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 10 August 2015, 7:58 PM EDT
Posts: 233
Thanks: 78
Thanked 2 Times in 2 Posts
Find a file modified yesterday and print it!

I was using the below command syntax to find whether the file(invoke.txt) was modified yesterday and if it is modified print only that particular file name. But it is giving me the list of all files and complete absolute paths. could you please help me, Thanks.

Syntax:

find /export/home/orainfodev/sam invoke.txt -type f -mtime -1

Output:

/export/home/orainfodev/sam
/export/home/orainfodev/sam/invoke2.txt
/export/home/orainfodev/sam/test.sh
Sponsored Links
    #2  
Old Unix and Linux 10-27-2008
joeyg's Unix or Linux Image
joeyg joeyg is offline Forum Staff  
modérateur
 
Join Date: Dec 2007
Last Activity: 27 August 2015, 2:01 PM EDT
Location: Within two miles of a Dunkin donuts.
Posts: 2,364
Thanks: 86
Thanked 164 Times in 150 Posts
Hammer & Screwdriver think you want to use -name

At first glance, I would think the following to specify a filename:

Code:
>find /export/home/orainfodev/sam -name invoke.txt -type f -mtime -1

If that doesn't work, you could always grep on your result Linux
Sponsored Links
    #3  
Old Unix and Linux 10-28-2008
Ariean Ariean is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 10 August 2015, 7:58 PM EDT
Posts: 233
Thanks: 78
Thanked 2 Times in 2 Posts
Hi Thanks for your reply, your syntax is still returning the complete path instead of only the file name when it is modified yesterday. What i want to do is capture the file name in a variable for further code development. Could you please throw some light on this on how to get only the file name.

Many Thanks!
    #4  
Old Unix and Linux 10-28-2008
joeyg's Unix or Linux Image
joeyg joeyg is offline Forum Staff  
modérateur
 
Join Date: Dec 2007
Last Activity: 27 August 2015, 2:01 PM EDT
Location: Within two miles of a Dunkin donuts.
Posts: 2,364
Thanks: 86
Thanked 164 Times in 150 Posts
Hammer & Screwdriver

This example returns the fully qualified name

Code:
> find ~/tmp/manipulate_data/ -name file01 -type f -mtime -2
/home/xxx/tmp/manipulate_data/file01

This example returns only the filename

Code:
> find ~/tmp/manipulate_data/ -name file01 -type f -mtime -2 | tr "/" "\n" | tail -1
file01

Sponsored Links
    #5  
Old Unix and Linux 12-24-2008
Ariean Ariean is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 10 August 2015, 7:58 PM EDT
Posts: 233
Thanks: 78
Thanked 2 Times in 2 Posts
The command which you sent me is just returning the last file in the directory even if it has mulitple files, Could you please let me how to get all the file names in that directory which were changed in last 2 days or so.

Thanks & Regards,
Ariean.
Sponsored Links
    #6  
Old Unix and Linux 12-27-2008
nullwhat nullwhat is offline
Registered User
 
Join Date: Sep 2008
Last Activity: 27 December 2008, 9:57 PM EST
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
pipe to awk to get only file name

pipe to awk

find ~/tmp/manipulate_data/ -name file01 -type f -mtime -2 | awk -F "\/" '{print $NF}'
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to find a file modified more than once kmsekhar Shell Programming and Scripting 2 02-28-2012 12:34 PM
How to find who opened/modified a file last Jabarod Shell Programming and Scripting 3 10-14-2011 05:03 PM
How to find the latest modified file from the unix server. sreenu80 Shell Programming and Scripting 2 10-16-2009 05:40 AM
find recently modified/ updated file lweegp Shell Programming and Scripting 9 03-21-2009 04:27 AM
how to write a shell script that print the last modified file ? FunnyWolF Shell Programming and Scripting 5 08-13-2008 02:25 AM



All times are GMT -4. The time now is 09:50 PM.