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 > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
pls help! complex find and replace lakanino Shell Programming and Scripting 2 03-12-2009 05:46 PM
complex find in script TimHortons Shell Programming and Scripting 5 01-27-2009 09:55 AM
Complex find grep or sed command sjburden Shell Programming and Scripting 3 05-31-2008 10:45 PM
complex grep command naamas03 Shell Programming and Scripting 0 11-21-2007 04:59 AM
advanced/complex uses of the find command Perderabo Answers to Frequently Asked Questions 0 05-04-2004 02:13 PM

Reply
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 10-22-2009
noam128 noam128 is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 4
complex find command

Hi all,
I am trying to execute the following command:
Code:
find 'path' -ls -exec cksum {} \;
As you can see this simply finds files from a given path and runs cksum on them.
My problem is this, if i have a FIFO in a directory the find tries to execute cksum on it and gets stuck.
From the man page i understood that i cannot use -type and -exec together
so i am quite stuck here.
any ideas?
  #2 (permalink)  
Old 10-22-2009
scottn scottn is offline Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,055
Hi.

Quote:
From the man page i understood that i cannot use -type and -exec together
You can indeed use type and exec together.
Code:
find 'path' -type f -ls -exec cksum {} \
  #3 (permalink)  
Old 10-22-2009
noam128 noam128 is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 4
Thank you for answering,
It is possible to use them together but when you use them together it is undefined who goes first. Sometimes first the type will be checked and then the exec activted and sometimes the other way around.

---------- Post updated at 06:53 AM ---------- Previous update was at 06:52 AM ----------

the solaris man page.
Solaris 5.10

---------- Post updated at 06:54 AM ---------- Previous update was at 06:53 AM ----------

Code:
Using -type is not sufficient to restrict the  type
     of  files on which the -exec command operates, because there
     is an inherent race condition between  the  type-check  per-
     formed by the find command and the time the executed command
     operates on the file argument.
---from the man page
  #4 (permalink)  
Old 10-22-2009
scottn scottn is offline Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,055
Hi.

The exec will be done depending on its place in the command. If you put it after the directory, filename, and type, etc. then it will after those are evanulated.

I've never experienced where the order is "underfined".
Bits Awarded / Charged to scottn for this Post
Date User Comment Amount
10-22-2009 noam128 N/A 5,000
  #5 (permalink)  
Old 10-22-2009
noam128 noam128 is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 4
Thank you scottn i will try it
  #6 (permalink)  
Old 10-22-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,872
The man page of which OS gave you that idea? I just checked on HP-UX and Linux, and neither -type nor -exec are mentioned in the description of the other. Just try it.
  #7 (permalink)  
Old 10-22-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,872
All variants of find I've encountered so far were left-associative, meaning the expressions were applied from left to right (following boolean order)

---------- Post updated at 14:09 ---------- Previous update was at 14:07 ----------

I think the race condition mentioned means that there is no guarantee that between the type check and the exec the entry doesn't change.
Reply

Bookmarks

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 05:17 PM.


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