find {start} -ls - Two Passes?


 
Thread Tools Search this Thread
Operating Systems AIX find {start} -ls - Two Passes?
# 1  
Old 12-08-2009
find {start} -ls - Two Passes?

I have a "find {start} -ls" command listing all files and dirs in on the whole filesystem.

As part of this it lists locations that contain temporary files and, sometimes when executing, it identifies a file but produces an ERROR when trying to list it.

ERROR thrown: find: bad status-- {filename}

This only occurs on temporary files which are not present when we manually look for them after the ERROR is seen. As such we believe that it is caused by the file vanishing between the "find {start}" part and the "-ls" part of the command.

Can someone confirm that "find -ls" uses two passes?
If this is the case, then can someone suggest a one pass alternative that gives the full path of each file/dir and long output?

Thanks in advance.
# 2  
Old 12-08-2009
Confirmed

The "problem" with AIX utilities is that I can't "crack them open" short of using ProbeVue or truss. (You have no access to the source.) But I can say this: The information you speak of comes from two different calls. readdir() "scans" for all files in a directory, and stat() (or variant) gives the ls info.

If you do not need the ls information then the call to stat() would (should) never be made unless you are filtering on access time or something like that.

My recommendation is to capture stderr so you can avoid the ugliness you speak of. If the error message is mixed in stdout, it would be trivial to write your own version in C that does not (watch out for soft links if you do). Another option is to look at the -R option to ls, it may produce similar output but generate errors that are different (once again, provided that you are getting stuff that should be stderr in your stdout).
# 3  
Old 12-08-2009
Top notch wfavorite. Thanks.

I will look into the effectiveness of using stderr. I'll let you know how I get on.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Red Hat

Find processes by start time

How do I find the process ( which might got completed ) which were ran at specific time. for e.g. I should be able to find below process after 2 hrs if I find by time 04:00 myuser 23285 22522 0 04:00 pts/0 00:00:00 /home/myuser/bin/abc.ksh (3 Replies)
Discussion started by: sameermohite
3 Replies

2. Shell Programming and Scripting

User interaction that passes the answer to a variable

Please tell me how to write a bash script that asks the user to enter a word and that passes the entered word to a variable. echo "Type a word and press the Enter key:" myVar=`cat` echo "You entered $myVar" The above code is very awkward, because it requires the user to enter... (2 Replies)
Discussion started by: LessNux
2 Replies

3. UNIX for Dummies Questions & Answers

Find Quarter Start and End Dates

Dear Members, Depending on the current date i should find out the start and end dates of the quarter. ex: Today date is 14-Nov-2011 then Quarter start date should be Oct 1 2011 and Quarter End date should be Dec 31 2011. How can i do this? Thanks Sandeep (1 Reply)
Discussion started by: sandeep_1105
1 Replies

4. Programming

x86 help value being store passes data type range

Hi im very new to x86 programming and was wonder if there a function or ways to solve my problem. I believe the reason for my inaccurate result are from passing floating point number beyond what a SWORD could hold. So far I been looking for a function that would allow me to round the floating... (1 Reply)
Discussion started by: godofdoom999
1 Replies

5. Shell Programming and Scripting

find strings at the start of a particular column

Hey, I have not posted here in a while. I have a biological data file that has 4 columns and I am interested in column 2. Column 5 contains a series of letters AGCT. Basically the file looks something like this Name AGGTTTTCCCCCCC L Q Name1 AGGTTTTAAAAAACC L Q Name2 ... (4 Replies)
Discussion started by: kylle345
4 Replies

6. Shell Programming and Scripting

KSH script: piping passes command-line arguments

Dear forum I have the following small script: #!/bin/ksh echo -e "abba-o" | awk -F '-' '{ print $2 }' | cut -b 1It needs to be ksh.. in bash I don't have this problem. If I run this on opensuse 10.2 I get this as output: e If I run this on suse enterprise 10 sp2 then I get this: o ... (1 Reply)
Discussion started by: gemtry
1 Replies

7. Shell Programming and Scripting

Check if parameter passes in contains certain string

Hi Guys, I am writing a Unix script which accepts a directory path as parameter $1 so something like /user5.data/WA/01 will be passed in. I want to determine if the directory path passed in contains "WA" as above (because then I need to do something specific if it does) What is the... (9 Replies)
Discussion started by: bcunney
9 Replies

8. Shell Programming and Scripting

script to find latest executable in particular directory and start that particular ex

i have a directory in which there are executable files and these files are added at runtime. now i need a shell script which will be called at a certain interval. this shell script should find the latest executable file in that directory and start that executable. care should be taken that once the... (6 Replies)
Discussion started by: kvineeth
6 Replies

9. Shell Programming and Scripting

Bash passes flags to shell wrong

Hi, first post, so hello to all. I have a Bash scripting problem that is driving me a bit nutty. It involves a program called 'convert' which is part of the ImageMagick collection. Normal usage from the commandline is: $ convert -resize 120x120 inputfile.jpg outputfile.jpg This is... (7 Replies)
Discussion started by: andyj
7 Replies
Login or Register to Ask a Question