Find a file modified yesterday and print it! | Unix Linux Forums | UNIX for Dummies Questions & Answers

  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 Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-27-2008
Ariean Ariean is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 23 September 2014, 3:03 PM EDT
Posts: 221
Thanks: 71
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 10-27-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
 
Join Date: Dec 2007
Last Activity: 22 September 2014, 3:20 PM EDT
Location: Out running a Marathon.
Posts: 2,329
Thanks: 72
Thanked 153 Times in 142 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
Sponsored Links
    #3  
Old 10-28-2008
Ariean Ariean is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 23 September 2014, 3:03 PM EDT
Posts: 221
Thanks: 71
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 10-28-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
 
Join Date: Dec 2007
Last Activity: 22 September 2014, 3:20 PM EDT
Location: Out running a Marathon.
Posts: 2,329
Thanks: 72
Thanked 153 Times in 142 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 12-24-2008
Ariean Ariean is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 23 September 2014, 3:03 PM EDT
Posts: 221
Thanks: 71
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 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 Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 10:23 PM.