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
Very Strange Behavior for redirection cahook Shell Programming and Scripting 5 08-08-2007 11:32 AM
Strange Real Memory usage behavior Skyybugg AIX 5 05-31-2007 10:17 AM
Strange Behavior on COM2 Elwood51 UNIX for Dummies Questions & Answers 0 08-02-2006 03:31 PM
Strange behavior from 'read' statements. (ksh - but could be same on other shells) alexop Shell Programming and Scripting 5 05-02-2006 11:14 AM
strange sed behavior Kevin Pryke UNIX for Dummies Questions & Answers 5 06-13-2003 04:34 AM

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 09-14-2005
jerardfjay jerardfjay is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 146
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
  #2 (permalink)  
Old 09-14-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,119
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 (permalink)  
Old 09-15-2005
jerardfjay jerardfjay is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 146
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 (permalink)  
Old 09-15-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
-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 (permalink)  
Old 09-15-2005
jerardfjay jerardfjay is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 146
Blowtorch,

Thanks for the explanation. Regards,

Jerardfjay
  #6 (permalink)  
Old 08-09-2007
bigearsbilly bigearsbilly is offline
Registered User
  
 

Join Date: Feb 2006
Location: Southern England
Posts: 104
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,


  #7 (permalink)  
Old 08-09-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,211
-ls is not GNU specific, it exists for example on Solaris without GNU find. However neither is it required by POSIX, which requires only the following:

Code:
-name  pattern
    
-nouser
    
-nogroup
    
-xdev
    
-prune
    
-perm [-]mode
    
-perm [-]onum
    
-type  c
   
-links  n
    
-user  uname
    
-group  gname
    
-size  n[c]

-atime  n

-ctime  n

-mtime  n

-exec  utility_name  [argument ...] ;
-exec  utility_name  [argument ...]   {} +

-ok  utility_name  [argument ...] ;
 
-print
    
-newer  file
    
-depth
HP-UX in many cases sticks to exactly the options specified in the standard, with no additional options.
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 03:34 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