Strange behavior of find and rm command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Strange behavior of find and rm command
# 8  
Old 05-13-2015
Ampsys,

Perhaps find is being more thorough than you. It is a very good tool, and better than using ls -1 and then mangling the output yourself.

Consider that find will descend directories and look at your directory structure to see how that might affect you. If you have many sub-directories and then more within that along with many many files, then find will be trawling them all because that is what you will have asked it to do.

If you don't want to use all the strengths of find, you can turn them off if you wish. If you have a poor directory design, then that is not the fault of find

This isn't really the place to complain about tools that run slowly because of your poor design.


Robin
This User Gave Thanks to rbatte1 For This Post:
# 9  
Old 05-13-2015
If ls -1 is convenient for you then you should compare with a flat run
Code:
find . \! -name . -prune -print

This User Gave Thanks to MadeInGermany For This Post:
# 10  
Old 05-13-2015
ls will wait hours then coredump on a large enough directory -- because it sorts, all the time, and that can't be turned off. find will never pull that trick on you. and returns results immediately.

If you know how to use it, find is extremely reliable. Its options are admittedly tricky.
# 11  
Old 05-14-2015
Quote:
Originally Posted by Corona688
ls will wait hours then coredump on a large enough directory -- because it sorts, all the time, and that can't be turned off. find will never pull that trick on you. and returns results immediately.

If you know how to use it, find is extremely reliable. Its options are admittedly tricky.
You can turn off sorting in ls when you use the -f option, but that has side effects (-f turns on -a, and the results are unspecified in you use -f with -l and a few other options).
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Strange behavior from kill command

I am getting some strange behaviour from the kill command. When I run the which command it says it points to /usr/bin/kill. When I look at my PATH I have /usr/bin in it. So why does running kill or /usr/bin/kill produce different outputs? ghost ~ $ which kill /usr/bin/kill ghost ~ $ kill... (5 Replies)
Discussion started by: cokedude
5 Replies

2. Shell Programming and Scripting

Strange Ctrl+C behavior

Hello All, I have a strange issue. I've created a shell script which connects to RMAN (Oracle Recovery Manager) and executes full DB backup. I then executed this script with nohup and in the background: $ nohup my_script.sh > logfile.log 2>&1 &The issue is that when I tried to take a look into... (6 Replies)
Discussion started by: JackK
6 Replies

3. Shell Programming and Scripting

Strange behavior of grep

Hi All, I am facing a strange problem while grepping for a process. Here is the small script that i have written. It will look for any process running with the parameter passed to the script. If no process is running it should print appropriate message. $ cat t.ksh #!/bin/ksh set -x ... (9 Replies)
Discussion started by: veeresh_15
9 Replies

4. AIX

Strange behavior with tar

I am trying to create an archive using tar. I am specifying a list of directories using the -L option. For testing purposes I created a simple directory structure: /backup/test /backup/test/test1 /backup/test/test2 The file specified by the -L option, named files.txt, contains:... (8 Replies)
Discussion started by: judykstra
8 Replies

5. UNIX for Advanced & Expert Users

Behavior of Find command

Centos 5.8 Lets say I have 2 nfs shares mounted to /folder1 and /folder2. If I do a find / -name *something* Will it also search the 2 nfs shares ? If so is there a way to avoid this? Thanks (2 Replies)
Discussion started by: whegra
2 Replies

6. AIX

Strange memory behavior

Hello together, i have a strange memory behavior on a AIX 7.1 System, which i cannot explain. The Filesystem-Cache will not be grow up and drops often after few minutes. I know if a file was deleted, that the same segment in the FS-Cache will also be cleared. But i am not sure if this is the... (8 Replies)
Discussion started by: -=XrAy=-
8 Replies

7. Ubuntu

Ubuntu strange behavior

It is so till login screen. I mean that when I boot my computer, Ubuntu shows a splash screen with mouse instead of Ubuntu logo and in the login screen it shows XUbuntu login screen... It began when I upgraded to previous kernel, I suppose, but I'm not sure... I can't say that it annoys me very... (6 Replies)
Discussion started by: Sapfeer
6 Replies

8. Programming

Strange behavior in C++

I have the following program: int main(int argc, char** argv){ unsigned long int mean=0; for(int i=1;i<10;i++){ mean+=poisson(12); cout<<mean<<endl; } cout<<"Sum of poisson: "<< mean; return 0; } when I run it, I get the... (4 Replies)
Discussion started by: santiagorf
4 Replies

9. Shell Programming and Scripting

strange behavior of find with xargs

Help me understand the right output. We have two machines. The first one is HP-UX machine1 B.11.00 U 9000/800 694339343 unlimited-user license The second one is AIX machine2 2 5 00067B2F4C00 with AIX version 5.2.0.0 Here is the command that I use on both systems on different... (9 Replies)
Discussion started by: jerardfjay
9 Replies
Login or Register to Ask a Question