The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-08-2005
negixx negixx is offline
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
  #2 (permalink)  
Old 07-08-2005
negixx negixx is offline
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
  #3 (permalink)  
Old 07-08-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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 (permalink)  
Old 07-08-2005
negixx negixx is offline
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
  #5 (permalink)  
Old 07-08-2005
negixx negixx is offline
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
  #6 (permalink)  
Old 07-08-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
ls -lu

will display the access times.
  #7 (permalink)  
Old 07-08-2005
negixx negixx is offline
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
Closed Thread

Bookmarks

Tags
mtime

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:49 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0