Find command question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find command question
# 1  
Old 07-08-2005
Find command question

Hi All,

I am trying to use the find command to search and delete files and have the following scenario. How come the file in the current directory is not getting listed out?

/glo71sw/716/devl/userdata/ftpord --> ls -lt XSKU*
-rw-r--r-- 1 root sys 137493 Jul 7 18:30 XSKU1925.DLD
-rw-r--r-- 1 root sys 164676 Jul 6 18:30 XSKU1924.DLD
-rw-r--r-- 1 root sys 114149 Jul 5 18:30 XSKU1923.DLD
-rw-r--r-- 1 root sys 45720 Jul 4 18:30 XSKU1922.DLD
-rw-r--r-- 1 root sys 180681 Jun 30 18:30 XSKU1920.DLD
-rw-r--r-- 1 root sys 152821 Jun 29 18:30 XSKU1919.DLD
-rw-r--r-- 1 root sys 150978 Jun 28 18:30 XSKU1918.DLD
-rw-r--r-- 1 root sys 174256 Jun 27 18:30 XSKU1917.DLD
-rw-rw-rw- 1 jlee dba 373736 Jun 25 11:06 XSKU1916.DLD
-rw-rw-rw- 1 jlee dba 353896 Jun 25 10:12 XSKU1915.DLD
-rw-rw-rw- 1 jlee dba 52328 Jun 25 07:43 XSKU1914.DLD
-rw-r--r-- 1 root sys 159551 Jun 24 18:30 XSKU1913.DLD
-rw-r--r-- 1 root sys 163624 Jun 23 18:30 XSKU1912.DLD
-rw-r--r-- 1 root sys 133796 Jun 22 18:30 XSKU1911.DLD
-rw-r--r-- 1 root sys 120108 Jun 21 18:30 XSKU1910.DLD
/glo71sw/716/devl/userdata/ftpord --> cd jo
/glo71sw/716/devl/userdata/ftpord/jo --> ls -lt XSKU*
-rw-r--r-- 1 root sys 137493 Jul 7 18:30 XSKU1925.DLD
-rw-r--r-- 1 root sys 164676 Jul 6 18:30 XSKU1924.DLD
-rw-r--r-- 1 root sys 114149 Jul 5 18:30 XSKU1923.DLD
-rw-r--r-- 1 root sys 45720 Jul 4 18:30 XSKU1922.DLD
-rw-r--r-- 1 root sys 180681 Jun 30 18:30 XSKU1920.DLD
-rw-r--r-- 1 root sys 152821 Jun 29 18:30 XSKU1919.DLD
-rw-r--r-- 1 root sys 150978 Jun 28 18:30 XSKU1918.DLD
-rw-r--r-- 1 root sys 174256 Jun 27 18:30 XSKU1917.DLD
-rw-rw-rw- 1 jlee dba 373736 Jun 25 11:06 XSKU1916.DLD
-rw-rw-rw- 1 jlee dba 353896 Jun 25 10:12 XSKU1915.DLD
-rw-rw-rw- 1 jlee dba 52328 Jun 25 07:43 XSKU1914.DLD
-rw-r--r-- 1 root sys 159551 Jun 24 18:30 XSKU1913.DLD
-rw-r--r-- 1 root sys 163624 Jun 23 18:30 XSKU1912.DLD
-rw-r--r-- 1 root sys 133796 Jun 22 18:30 XSKU1911.DLD
-rw-r--r-- 1 root sys 120108 Jun 21 18:30 XSKU1910.DLD
/glo71sw/716/devl/userdata/ftpord/jo --> cd ..
/glo71sw/716/devl/userdata/ftpord --> find . -name 'XSKU*' -type f -atime 2
./jo/XSKU1923.DLD
/glo71sw/716/devl/userdata/ftpord -->


Should I also get the result
./XSKU1923.DLD?

Actually, I only need to delete files in current directory, bypassing any files found under its subdirectories. Please advise.

Thanks!

Joseph
# 2  
Old 07-08-2005
If I try to enter a 0 or a -n in the atime option, I then get the files from the currect directory.
test=/glo71sw/716/devl/userdata/ftpord

/glo71sw/716/devl/userdata/ftpord --> find $test -name 'XSKU*' -type f -atime 0
/glo71sw/716/devl/userdata/ftpord/XSKU1910.DLD
/glo71sw/716/devl/userdata/ftpord/XSKU1911.DLD
/glo71sw/716/devl/userdata/ftpord/XSKU1912.DLD
/glo71sw/716/devl/userdata/ftpord/XSKU1913.DLD
/glo71sw/716/devl/userdata/ftpord/XSKU1914.DLD
/glo71sw/716/devl/userdata/ftpord/XSKU1915.DLD
/glo71sw/716/devl/userdata/ftpord/XSKU1916.DLD
/glo71sw/716/devl/userdata/ftpord/XSKU1917.DLD
/glo71sw/716/devl/userdata/ftpord/XSKU1918.DLD
/glo71sw/716/devl/userdata/ftpord/XSKU1919.DLD
/glo71sw/716/devl/userdata/ftpord/XSKU1920.DLD
/glo71sw/716/devl/userdata/ftpord/jo/XSKU1925.DLD
/glo71sw/716/devl/userdata/ftpord/XSKU1922.DLD
/glo71sw/716/devl/userdata/ftpord/XSKU1923.DLD
/glo71sw/716/devl/userdata/ftpord/XSKU1924.DLD
/glo71sw/716/devl/userdata/ftpord/XSKU1925.DLD
/glo71sw/716/devl/userdata/ftpord -->


Thanks!

Negixx
# 3  
Old 07-08-2005
Try this:
Code:
find $test -type f -name 'XSKU*' -maxdepth 1 -atime 2 | xargs ls -l

This will list all files starting with XSKU, accessed exactly 2 days ago, and in the current directory.

Cheers!
# 4  
Old 07-08-2005
I think I know what happened.

I created the directory "jo" today and then copied all files to this new directory. This action must have updted the "access" time of the files to current (0). But when I changed the option to "mtime" I got all files.....

Is there a way to display the access time of the file?

Thanks!

Joseph
# 5  
Old 07-08-2005
thanks!

the maxdepth options does not work for us.

I tried using the "-prune" options as previoulsly stated but I am getting an error that says invalid conjunction....I will try it again...

negixx
# 6  
Old 07-08-2005
ls -lu

will display the access times.
# 7  
Old 07-08-2005
Thanks!

find command works now....whew! Smilie

find . \( -name 'XSKU*' -o ! -name . -prune \) -type f -mtime 2

Thanks!

negixx
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

A question on find command

I need to find all files with file names starting with alert and ending with .log I mean, the following files should be returnrned alertTST.log alertabcdefgh.log How can i do this ? (4 Replies)
Discussion started by: kraljic
4 Replies

2. Shell Programming and Scripting

find command question

Hi all, I want to use find to 'find' files older than a file. The command I have come up with so far is find . -type f ! -newer filename -print | grep -v filename If I dont use the -v then the filename is included in the output is there a better way of formulating this command... (1 Reply)
Discussion started by: jonnyd
1 Replies

3. UNIX for Dummies Questions & Answers

Find Command Question

I was using this find command to search for this string find /usr/reports -name '*.txt' -type f -exec grep -l tbl_out:add_19 {} \; > /usr/work/junk.txt My question is, if I want to search another type of file extension besides '*.txt' how can I include it on the same line to say something... (5 Replies)
Discussion started by: NycUnxer
5 Replies

4. Shell Programming and Scripting

Find command question

Hi, I want to search in the log directory only. This log directory exists at mutiple places in my directory tree. I know that to exclude any directory we have option - prune but can we do the just opposite of it.. just check a single directory and exclude the rest. thanks (3 Replies)
Discussion started by: manojgarg
3 Replies

5. Shell Programming and Scripting

find command question

Hi I need to find the command ("find" , "grep" etc..) which would give me the full path and file name of all the files in the entire directory tree which contain the line "/bbsrc/doc/". What would be the most efficient way to do it? Thanks a lot for advice -A (6 Replies)
Discussion started by: aoussenko
6 Replies

6. UNIX for Dummies Questions & Answers

awk and find command question

Hello! I have written this script: for file in "$( find $dirName -type d )" do echo "$file" echo "hello" done but as a result I get all the directories and in the end the work "hello". Shouldn't it print the word "hello" after printing the name of each directory and not in the end? ... (1 Reply)
Discussion started by: GeorgeP
1 Replies

7. UNIX for Dummies Questions & Answers

FIND command question revisited

I'm using this in AIX to find what file contains the value 'batch' in it, in all directories. find / -type f -exec grep -l batch {} /dev/null \; My question is, what if I only wanted to search *.sh files, and I wanted to pipe the results to a file called 'batch_find.txt'. How could I code... (3 Replies)
Discussion started by: NycUnxer
3 Replies

8. UNIX for Dummies Questions & Answers

question on find and remove command

Hi All, I have wrote a command to find a and remove all *.apr files ina directory . Now i got the request as reversed , They want to remove all files except *.apr in the direcory . Is it possible to do that in a find comand else i have give an explicit find command to all *. files to... (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

9. UNIX for Dummies Questions & Answers

question about find command

I am not sure if this question has been answered earlier at the Unix Forums. I tried a search but could not find anything. So here it goes... I am looking for a log file under /home. find /home dklog.log -print This prints all the directories it traverses while looking for the file and in... (4 Replies)
Discussion started by: hnhegde
4 Replies

10. UNIX for Dummies Questions & Answers

'find' command question

my solaris text talks about the 'find' command... it further goes to talk about an "action" used with the find command. I am completely confused as to what the {} do with the find comand. the explanation is this: "A set of braces, {}, delimits where the file name is passed to the command from... (2 Replies)
Discussion started by: xyyz
2 Replies
Login or Register to Ask a Question