Find cmd not working as expected


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find cmd not working as expected
# 1  
Old 08-28-2007
Find cmd not working as expected

Hi,

i wan to search the file starting with Admin into the directory Output. I am running below command:

find /appl/Output -name "Admin*" -prune

but this command is going into the sub directories present under output. I do not want to search under sub directories. Any help will be highly appreciated.

Thanks!!
# 2  
Old 08-28-2007
try -maxdepth as follows..

Code:
       -maxdepth levels
              Descend at most levels (a non-negative integer) levels of direc-
              tories below the command line arguments.   `-maxdepth  0'  means
              only  apply the tests and actions to the command line arguments.

# 3  
Old 08-28-2007
-maxdepth option is not allowed

Thanks for ur quick reply. but -maxdepth option is not supported with my unix verison. I have version 5 of unix.
when i tried to run find /appl/Output -name "Admin*" -prune -maxdepth 0 it gave error saying "find: 0652-017 -maxdepth is not a valid option."

Pls help.
# 4  
Old 08-28-2007
Why are you using find if you are not recursing through directories?

echo /appl/Output/Admin*
# 5  
Old 08-28-2007
actually i want to search based upon the file created time & file modified time. For that i have to use find command.
# 6  
Old 08-29-2007
you could use the option mtime in the find command to search based on the modified time of the file.
# 7  
Old 08-29-2007
either you can use--

ls -ltr /appl/Output/Admin*

Thanks
Namish
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Manipulate files with find and fuser not working as expected on SunOs

Greetings, For housekeeping, I use the following command: find /some/path -type f -name "*log*" ! -exec fuser -s "{}" 2>/dev/null \; -exec ls -lh {} \; It finds all log files not currently in use by a process and manipulates them. This command always works on linux and redhat machines,... (2 Replies)
Discussion started by: dampio
2 Replies

2. UNIX for Advanced & Expert Users

Test -e not working as expected (by me)

I ran into the following and still do not understand entirely the rationale behind this. If someone could explain why things are as they are I'd be thankful. The following was tested on AIX 7.1 with ksh88, but i suspect that to be ubiquitous. In an installation routine i had to create a set of... (6 Replies)
Discussion started by: bakunin
6 Replies

3. Shell Programming and Scripting

basename not working as expected from find -exec

I have the following files in a directory > ls -1 /tmp/test/dir/ file with spaces 1.ogg file with spaces 2.oggI am running the following to echo the filenames but alter the file extension on the files to .mp3 instead of .ogg ( I am going to run ffmpeg against the files ultimately, but keeping... (2 Replies)
Discussion started by: jelloir
2 Replies

4. Red Hat

how passwd cmd is working

how unix users able to change their password even if they have only read permissions and how backend process will be happening can u explain me which are files need to involved in this process (3 Replies)
Discussion started by: ponmuthu
3 Replies

5. Shell Programming and Scripting

Why this is not working in expected way?

total=0 seq 1 5 | while read i ; do total=$(($total+$i)) echo $total done echo $totalThis outputs: 1 3 6 10 15 0whereas I am expecting: 1 3 6 10 15 15My bash version: (4 Replies)
Discussion started by: meharo
4 Replies

6. Shell Programming and Scripting

Find cmd not working correctly in script

I am trying to copy 2 types of files so I can archive them. I tested with a set of commands: touch -t $(date -d "-60 day" +%Y%m%d) WORKDIR/REF find TARGETDIR/ -type f -maxdepth 1 -iname \*.out\* -or -iname \*.log\* ! -newer WORKDIR/REF -exec ls -l {} \; This correctly lists any files in the... (2 Replies)
Discussion started by: prismtx
2 Replies

7. Solaris

Find cmd working in Linux and not in SunSolaris 5.8

find . -type f -mtime -1 -ls command not working in sun solaris 5.8 (4 Replies)
Discussion started by: navjotbaweja
4 Replies

8. UNIX for Dummies Questions & Answers

Find command not working as expected

I have a script with a find command using xargs to copy the files found to another directory. The find command is finding the appropriate file, but it's not copying. I've checked permissions, and those are all O.K., so I'm not sure what I'm missing. Any help is greatly appreciated. This is... (2 Replies)
Discussion started by: mpflug
2 Replies

9. Shell Programming and Scripting

su cmd not working

HI all, i want to run various Unix cmds thru a java prg. following is the code which i have written. ------------------------------------------------------------------- import java.io.*; class Run { public static void main(String args) { String ls_str; try{ Process cmd_su =... (1 Reply)
Discussion started by: sonbag_pspl
1 Replies

10. Shell Programming and Scripting

which not working as expected

Hello. Consider the following magic words: # ls `which adduser` ls: /usr/sbin/adduser: No such file or directory # Hmmm... Then: # ls /usr/sbin/adduser /usr/sbin/adduser # Now what? Unforunately this little sniippet is used in my debian woody server's mysql pre install script.... (2 Replies)
Discussion started by: osee
2 Replies
Login or Register to Ask a Question