The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
question on find and remove command arunkumar_mca UNIX for Dummies Questions & Answers 1 12-10-2007 09:54 PM
question about find command hnhegde UNIX for Dummies Questions & Answers 4 10-26-2006 12:00 PM
how to find a file named vijay in a directory using find command amirthraj_12 UNIX for Dummies Questions & Answers 5 10-25-2006 02:39 PM
command find returned bash: /usr/bin/find: Argument list too long yacsil Shell Programming and Scripting 1 12-15-2003 02:38 PM
'find' command question xyyz UNIX for Dummies Questions & Answers 2 03-07-2002 03:28 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-08-2005
Registered User
 

Join Date: Jun 2005
Location: St. Louis, MO
Posts: 32
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
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-08-2005
Registered User
 

Join Date: Jun 2005
Location: St. Louis, MO
Posts: 32
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
Reply With Quote
  #3 (permalink)  
Old 07-08-2005
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,325
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!
Reply With Quote
  #4 (permalink)  
Old 07-08-2005
Registered User
 

Join Date: Jun 2005
Location: St. Louis, MO
Posts: 32
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
Reply With Quote
  #5 (permalink)  
Old 07-08-2005
Registered User
 

Join Date: Jun 2005
Location: St. Louis, MO
Posts: 32
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
Reply With Quote
  #6 (permalink)  
Old 07-08-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,453
ls -lu

will display the access times.
Reply With Quote
  #7 (permalink)  
Old 07-08-2005
Registered User
 

Join Date: Jun 2005
Location: St. Louis, MO
Posts: 32
Thanks!

find command works now....whew!

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

Thanks!

negixx
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
mtime

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0