DOYENSYS Knowledge Portal



We Welcome you to visit our DOYENSYS KNOWLEDGE PORTAL :

Click here Navigate to Doyensys Knowledge Portal

Monday, February 20, 2012

Finding files in Unix based on specific criteria


FIND FILES THAT WERE MODIFIED/ACCESSED WITHIN A SPECIFIED TIME

            $   find  /<your path>  -mtime   1  -type   f 
This command would return files modified  in the last 24 hours .
You can use -mtime option to return a list of files that were last modified N*24 hours ago. For example to find a file in last month (30 days) you would need to use -mtime +30 options.
  • -mtime +30   means you are looking for a file modified 30 days ago.
  • -mtime -30    means less than 30 days.
  • -mtime 30      If you skip + or - it means exactly 30 days
      -type f      searches only for files and not directories
To list the files in the directory tree that were modified within the past five minutes, type
$  find /<your path>  -mmin -5

To return a list of files that were accessed in the last 24 hours you would need to use the –atime option.
find  /<your path>   -atime   1  -type   f 

******************************************************************

FINDING FILES WITH A SPECIFIC EXTENTION WITHIN A DIRECTORY

         $  find   /<your path>   -name  "*.cfg"
The command –name matches the file names with the specified pattern

******************************************************************

FINDING FILES BASED ON THE FILE-PERMISSIONS


Files with execute permission for group :
$ find /<your path>  -perm g=x   -type f 
Files with execute permission for others:
$ find /<your path>  -perm  o=x   -type f
Where ‘g’ denotes groups and ‘o’ denotes others. x denotes execute permission.
******************************************************************

KILLING ACTIVE UNIX PROCESSES FOR SPECIFIC COMPONENTS


ps -ef |grep applmgr |grep <Component Name> |grep -v grep |awk '{print $2}' |xargs kill -9

For example to kill all active forms processes, we can use the following command:


ps -ef |grep applmgr |grep frm | grep -v grep |awk '{print $2}' |xargs kill -9 

1 comments:

jennysemon said...

It is good to see your blog here.This is simply great tips regarding UNIX programming.Thanks for sharing it.

excel courses sydney