INSTALLATION DOCUMENTS BY RAVI

Friday, April 14, 2017

Find commands in linux and unix

1. Files got updated in last hour
#find . -mmin -60

2. Files got updated in last day
#find . -mtime -1

3. Files accessed in last 1 hour and last 1 day
#find . -amin -60
#find . -atime -1

4. Files changed in last 1 hour and last 1 day
#find . -cmin -60
#find / -ctime -1

5. Files which are modified after the modification of a particular file
#find -newer FILE

6. Files which are accessed after modification of a particular file
#find -anewer FILE

7. Files whose status got changed after the modification of a particular file
#find -cnewer FILE

8. Perform any operation on files found from find command
#find <condition to find files> -exec <operation> \;
Eg:  
 #find -mmin -60 -exec ls -l {} \;

9. Searching only in the current file system
#find / -name "*.log"
#find / -xdev -name "*.log"

10. Using more than one {} in same command
#find -name "*.txt" cp {} {}.bkup \;

11. Redirecting errors to /dev/null
#find -name "*.txt" 2>>/dev/null

12. Substitute space with underscore in the file name
#find . -type f -iname "*.mp3" -exec rename "s/ / _/g" {} \;


No comments:

Post a Comment

Loading xml file data to oracle table using python

Sample xml file (test.xml): <?xml version="1.0"?> <data>     <customer name="Ravi" >     ...