Showing posts with label Find. Show all posts
Showing posts with label Find. Show all posts

Thursday, November 15, 2012

How to find any specific file(s) and then copy those in a directory?

It was tested recently on Redhat Linux 6. The requirement is to find the files owned by some user and copy all those files into a single pre-selected directory. There are at least two ways (I am sure there are even more ways to do this - but here is what I used)

Method 1:
# find / -user testuser -type f -exec cp {} /root/BACKUP \;



Method 2:
# find / -user testuser -type f | cpio -pvdmu /root/BACKUP 

Thursday, February 9, 2012

Microsoft Excel forumula for text

I had a requirement where I was having an excel sheet and based on one column's data (which is a text), I had to populate another column to provide analysis.

Basically, I wanted to find keyword prjtmp and if it is found in given cell, I want to put "DONT WORRY" in the result column. Below was the formula I put in the desired cell and BOOM!!! It worked!!! :)


=IF(ISNUMBER(SEARCH("*prjtmp*",C2)),"DONT WORRY","")

Thursday, January 3, 2008

Find command

Basic uses of find

How to find a file?
$ find /export/home -name testfile

How to find a file and its details?
$ find /export/home -name testfile -exec ls -l {} \;

How to find a file which is not modified since past 60 days?
$ find /export/home -mtime +60 -exec ls -l {} \;

How to find a file which is not accessed since past 60 days?
$ find /export/home -atime +60 -exec ls -l {} \;


How to find a directory
$ find /var/adm -type d


Advance uses of Find command

How to find a file which contains "report" word in it?
$ find /export/home -type f -exec grep "report" '{}' /dev/null \;