Finding Long Unaccessed Files and Running Commands on Found Files


We all have old files on our systems and in our home directories that have not been accessed in a long time. To find files in a home directory that have not been accessed in the last 200 days, you would issue the following command:

 #  find . -atime +200 -print  ./hp/.Xdefaults ./hp/.bash_logout ./hp/.bash_profile ./hp/.bashrc ./hp/.kde/share/apps/kfm/desktop ./hp/.kde/share/config/desktop0rc ./hp/.kde/share/config/kcmdisplayrc ./hp/.kde/share/config/kfmrc ./hp/.kde/share/config/kpanelrc ./hp/.kde/share/config/kvtrc ./hp/.kderc ./hp/Desktop/.directory ./hp/Desktop/Printer.kdelnk ./hp/Desktop/Templates/Device.kdelnk ./hp/Desktop/Templates/Ftpurl.kdelnk ./hp/Desktop/Templates/MimeType.kdelnk ./hp/Desktop/Templates/Program.kdelnk ./hp/Desktop/Templates/URL.kdelnk ./hp/Desktop/Templates/WWWUrl.kdelnk ./hp/Desktop/cdrom.kdelnk ./hp/Desktop/floppy.kdelnk ./hp/.screenrc ./hp/.bash_history ./test/.Xdefaults ./test/.bash_logout ./test/.bash_profile ./test/.bashrc ./test/.kde/share/apps/kfm/desktop ./test/.kde/share/config/desktop0rc ./test/.kde/share/config/kcmdisplayrc ./test/.kde/share/config/kfmrc ./test/.kde/share/config/kpanelrc ./test/.kde/share/config/kvtrc ./test/.kderc ./test/Desktop/.directory ./test/Desktop/Printer.kdelnk ./test/Desktop/Templates/Device.kdelnk ./test/Desktop/Templates/Ftpurl.kdelnk ./test/Desktop/Templates/MimeType.kdelnk ./test/Desktop/Templates/Program.kdelnk ./test/Desktop/Templates/URL.kdelnk ./test/Desktop/Templates/WWWUrl.kdelnk ./test/Desktop/cdrom.kdelnk ./test/Desktop/floppy.kdelnk ./test/.screenrc ./test/linux1.xwd ./test/.bash_history # 

Several files were produced as a result of this search. I could run the same command and add to it an ls -l command so I could look at additional information on the file with the following command:

 #  find . -atime +200 -exec ls -l {} \;  -rw-r--r--   1 hp       hp        1422 Aug 28   ./hp/.Xdefaults -rw-r--r--   1 hp       hp          24 Aug 28   ./hp/.bash_logout -rw-r--r--   1 hp       hp         230 Aug 28   ./hp/.bash_profile -rw-r--r--   1 hp       hp         124 Aug 28   ./hp/.bashrc -rw-r--r--   1 hp       hp         260 Aug 28   ./hp/.kde/share/apps/kfm/desktop -rw-r--r--   1 hp       hp         234 Aug 28   ./hp/.kde/share/config/desktop0rc -rw-r--r--   1 hp       hp          49 Aug 28   ./hp/.kde/share/config/kcmdisplayrc -rw-r--r--   1 hp       hp          95 Aug 28   ./hp/.kde/share/config/kfmrc -rw-r--r--   1 hp       hp         456 Aug 28   ./hp/.kde/share/config/kpanelrc -rw-r--r--   1 hp       hp         255 Aug 28   ./hp/.kde/share/config/kvtrc -rw-r--r--   1 hp       hp         966 Aug 28   ./hp/.kderc -rw-r--r--   1 hp       hp          85 Aug 28   ./hp/Desktop/.directory -rw-r--r--   1 hp       hp         222 Aug 28   ./hp/Desktop/Printer.kdelnk -rw-r--r--   1 hp       hp         607 Aug 28   ./hp/Desktop/Templates/Device.kdelnk -rw-r--r--   1 hp       hp         296 Aug 28   ./hp/Desktop/Templates/Ftpurl.kdelnk -rw-r--r--   1 hp       hp         324 Aug 28   ./hp/Desktop/Templates/MimeType.kdelnk -rw-r--r--   1 hp       hp         170 Aug 28   ./hp/Desktop/Templates/Program.kdelnk -rw-r--r--   1 hp       hp         411 Aug 28   ./hp/Desktop/Templates/URL.kdelnk -rw-r--r--   1 hp       hp         458 Aug 28   ./hp/Desktop/Templates/WWWUrl.kdelnk -rw-r--r--   1 hp       hp         376 Aug 28   ./hp/Desktop/cdrom.kdelnk -rw-r--r--   1 hp       hp         378 Aug 28   ./hp/Desktop/floppy.kdelnk -rw-rw-r--   1 hp       hp        3505 Aug 28   ./hp/.screenrc -rw-------   1 hp       hp          34 Aug 28   ./hp/.bash_history -rw-r--r--   1 test     test      1422 Aug 28   ./test/.Xdefaults -rw-r--r--   1 test     test        24 Aug 28   ./test/.bash_logout -rw-r--r--   1 test     test       230 Aug 28   ./test/.bash_profile -rw-r--r--   1 test     test       124 Aug 28   ./test/.bashrc -rw-r--r--   1 test     test       260 Aug 28   ./test/.kde/share/apps/kfm/desktop -rw-r--r--   1 test     test       234 Aug 28   ./test/.kde/share/config/desktop0rc -rw-r--r--   1 test     test        49 Aug 28   ./test/.kde/share/config/kcmdisplayrc -rw-r--r--   1 test     test        95 Aug 28   ./test/.kde/share/config/kfmrc -rw-r--r--   1 test     test       456 Aug 28   ./test/.kde/share/config/kpanelrc -rw-r--r--   1 test     test       255 Aug 28   ./test/.kde/share/config/kvtrc -rw-r--r--   1 test     test       966 Aug 28   ./test/.kderc -rw-r--r--   1 test     test        85 Aug 28   ./test/Desktop/.directory -rw-r--r--   1 test     test       222 Aug 28   ./test/Desktop/Printer.kdelnk -rw-r--r--   1 test     test       607 Aug 28   ./test/Desktop/Templates/Device.kdelnk -rw-r--r--   1 test     test       296 Aug 28   ./test/Desktop/Templates/Ftpurl.kdelnk -rw-r--r--   1 test    test       324 Aug 28  ./test/Desktop/Templates/MimeType.kdelnk -rw-r--r--   1 test     test       170 Aug 28   ./test/Desktop/Templates/Program.kdelnk -rw-r--r--   1 test     test       411 Aug 28   ./test/Desktop/Templates/URL.kdelnk -rw-r--r--   1 test     test       458 Aug 28   ./test/Desktop/Templates/WWWUrl.kdelnk -rw-r--r--   1 test     test       376 Aug 28   ./test/Desktop/cdrom.kdelnk -rw-r--r--   1 test     test       378 Aug 28   ./test/Desktop/floppy.kdelnk -rw-rw-r--   1 test     test      3505 Aug 28   ./test/.screenrc -rwxrwxrwx   1 root     root    614955 Aug 28   ./test/linux1.xwd -rw-------   1 test     test        13 Aug 28   ./test/.bash_history # 
graphics/finda_icon.gif

This command produces the same output as the previous example and puts the output of find in the place where the curly brackets appear. The ls -l will use the filename produced by find , which is inside the curly brackets, as an argument. You follow the command with a semicolon so that the shell knows where the command ends, and you must use the backslash as an escape for the semicolon so that the find command recognizes the semicolon.



HP-UX 11i Systems Administration Handbook and Toolkit
HP-UX 11i Systems Administration Handbook and Toolkit (2nd Edition)
ISBN: 0131018833
EAN: 2147483647
Year: 2003
Pages: 301

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net