strange behavior of find with xargs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting strange behavior of find with xargs
# 1  
Old 09-14-2005
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 directories

find . -size 30000 | xargs ls -l

On the HP system, this lists everything on the directory irrespective of the file size. I know this for a fact because, when I do a wc -l on the above as well as ls -l | wc -l, I get the same result/number.

On the AIX system, though the find command lists the files that are >= to size specified and then does output a line with ":" by itself followed by the listing of all the files.

I would assume the intent of the above command is to list the files in the current directory which are >= to the size only, However I dont seem to be able to get that in these systems. The closest to the result that I seem to get is on the AIX system until the line by the ":" by itself.

Am I wrong in my assumption or is there something more to this? Can someone please explain. Thanks.

Jerardfjay Smilie
# 2  
Old 09-14-2005
Do "find . -size 30000" by itself. If no files at all are found, then
find . -size 30000 | xargs ls -l
will run "ls -l" with no arguments at all.
# 3  
Old 09-15-2005
Quote:
Originally Posted by Perderabo
Do "find . -size 30000" by itself. If no files at all are found, then
find . -size 30000 | xargs ls -l
will run "ls -l" with no arguments at all.
Perderabo,

did you mean if files were found for "find . -size 30000" then run the find again with the xargs command?

Jerardfjay
# 4  
Old 09-15-2005
-EDIT-
What Perderabo means is:
-EDIT-
When you run find (in this case), the command will return the names of files that are larger than 30000 bytes in size. When you pipe the output of find to xargs, the filenames are supplied to xargs and the command specified (in this case ls -l) is run on the filenames.

If no files are found, then 'ls -l' will be run without any arguments, i.e. the output would be same as running 'ls -l' in the current working directory and will give full listing as the output.

Hope this helps!
# 5  
Old 09-15-2005
Blowtorch,

Thanks for the explanation. Regards,

Jerardfjay
# 6  
Old 08-09-2007
you may 'find' [sic] that some versions of find
on certain flavours of unix
do not include an implicit -print of found files

i.e. you need to do find . -print

also find already has an -ls option,


Smilie
# 7  
Old 08-09-2007
-ls and -fls are gnu extensions.

HPUX 11.0 find does not support that, for example.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Strange behavior of find and rm command

Hi I run the below command to find and delete *.xml files 90 or more days old. find . -type f -name '*.xml' -mtime +90 -exec rm {} \; find: stat() error ./Hello/2014_EMPTY.xml: No such file or directory ./Hello/2014_EMPTY_8011.xml: No such file or directory ..... .... If the file... (10 Replies)
Discussion started by: mohtashims
10 Replies

3. 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

4. Red Hat

strange mail behavior

Hi I have script to to take backup and send mail to a group once a day. One strange behavior I have observed recently is that most of the time the mail we receive is fine . But someday it just sends out mail without any subject with undisclosed recipients. I dont know how to find the cause... (0 Replies)
Discussion started by: ningy
0 Replies

5. 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

6. 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

7. Shell Programming and Scripting

nawk strange behavior

Dear guys; when deleting repeated lines using nawk as below ; Why the below syntax works? nawk ' !a++' infile > outfile and when using the other below syntax the nawk doesn't work? nawk ' { !a++ } ' infile > outfile or nawk ' { !a++ } ' infile > outfile BR (4 Replies)
Discussion started by: ahmad.diab
4 Replies

8. Shell Programming and Scripting

Very Strange Behavior for redirection

I have searched far and wide for an explanation for some odd behavior for output redirection and haven't come up with anything. A co-worker was working on old scripts which have run for years and embedded in their code were output redirects which worked for the script during execution and then... (5 Replies)
Discussion started by: cahook
5 Replies

9. UNIX for Dummies Questions & Answers

strange sed behavior

I have a file called products.kp which contains, for example, 12345678,1^M 87654321,2^M 13579123,3 when I run the command cat products.kp| sed -f kp.sed where kp.sed contains s,^M,, I get the output 12345678,1 87654321,2 13579123,3 (5 Replies)
Discussion started by: Kevin Pryke
5 Replies
Login or Register to Ask a Question