×
UNIX.COM Login
Username:
Password:  
Show Password






👤
Admin Notice


OS X (Apple)

OS X is a line of Unix-based graphical operating systems developed, marketed, and sold by Apple.

Warning using 'find'.

OS X (Apple)


Tags
find, solved

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 11-08-2016
wisecracker's Unix or Linux Image
wisecracker wisecracker is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 15 July 2018, 2:34 PM EDT
Location: Loughborough
Posts: 1,286
Thanks: 387
Thanked 352 Times in 277 Posts
Warning using 'find'.

This is more of a discovery than a bug and for OSX 10.12.x, maybe earlier but I don't have them now.

Consider this code:-


Code:
		# Auto-find the correct path and "sox" file, but it WILL take a very long time...
		# NOTE: It searches from YOUR HOME directory structure only, just modify to suit your machine if 'SOX' is elsewhere.
		capturepath=$(find "$HOME" -name 'sox' 2>/dev/null)

This works perfectly with a virgin install of SOX, (in this case inside my $HOME directory).
I decided to install the latest version of SOX 14.4.2.
I then placed the original into the "Trash", that is "$HOME"/.Trash/ directory.
Next I launched "./AudioScope.sh" and as expected DEMO worked perfectly.
THEN; I decided to run the SOX command inside the code and the code literally crashed out.
The error report pointed to "$HOME/.Trash/sox-14.4.0/sox" so it looks as though the 'find' command searches the "$HOME"/.Trash/ directory also.
Unlike the AMIGA, OSX cannot run code from inside its Trashcan hence the total crashout.
So let this be a warning to others if you have a previous version of something in the Trashcan and another version elsewhere and you intend to find it using the 'find' command then EXPECT a bug as "$HOME"/.Trash/ is searched early in the scan.

I hope this is useful to others.

Bazza...
Sponsored Links
    #2  
Old 11-11-2016
xbin xbin is offline
Registered User
 
Join Date: Feb 2007
Last Activity: 21 May 2017, 1:50 PM EDT
Posts: 132
Thanks: 11
Thanked 30 Times in 30 Posts
Just exclude the .Trash directory in your find statement.


Code:
find "$HOME" -path '*.Trash*' -prune -o \( -name sox -print \)

The Following User Says Thank You to xbin For This Useful Post:
wisecracker (11-13-2016)
Sponsored Links
    #3  
Old 11-11-2016
MadeInGermany MadeInGermany is offline Forum Staff  
Moderator
 
Join Date: May 2012
Last Activity: 15 July 2018, 9:32 PM EDT
Location: Simplicity
Posts: 4,151
Thanks: 365
Thanked 1,417 Times in 1,273 Posts
Get used to the following, that will skip "hidden" directories like .Trash/ .git/ .snapshot/ .Wastebasket/ ...


Code:
find "$HOME" -type d -name '.?*' -prune -o -type f -name 'sox' -print

Note the -print is important. Otherwise it defaults to also print the pruned directories!
The Following 2 Users Say Thank You to MadeInGermany For This Useful Post:
Corona688 (04-03-2017), wisecracker (11-13-2016)
    #4  
Old 11-13-2016
wisecracker's Unix or Linux Image
wisecracker wisecracker is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 15 July 2018, 2:34 PM EDT
Location: Loughborough
Posts: 1,286
Thanks: 387
Thanked 352 Times in 277 Posts
Thanks guys.

Will update code soon...

I never guessed that the '.Trash' folder would be searched...
Sponsored Links
    #5  
Old 11-16-2016
wisecracker's Unix or Linux Image
wisecracker wisecracker is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 15 July 2018, 2:34 PM EDT
Location: Loughborough
Posts: 1,286
Thanks: 387
Thanked 352 Times in 277 Posts
Hi MadeInGermany...

Many thanks the code works superbly...

I have acknowledged your input inside the Manual section of AudioScope.sh...

<Thumbs Up sign here...>
Sponsored Links
    #6  
Old 11-16-2016
rbatte1 rbatte1 is offline Forum Staff  
Root armed
 
Join Date: Jun 2007
Last Activity: 13 July 2018, 1:03 PM EDT
Location: Lancashire, UK
Posts: 3,582
Thanks: 1,590
Thanked 706 Times in 633 Posts
Try character sequence :b: in your post.





Kind regards,
Robin
The Following User Says Thank You to rbatte1 For This Useful Post:
wisecracker (11-16-2016)
Sponsored Links
    #7  
Old 03-25-2017
f77hack f77hack is offline
Registered User
 
Join Date: Jan 2016
Last Activity: 16 April 2018, 10:03 PM EDT
Location: 3rd planet
Posts: 32
Thanks: 27
Thanked 1 Time in 1 Post
Quote:
Originally Posted by MadeInGermany View Post
Get used to the following, that will skip "hidden" directories like .Trash/ .git/ .snapshot/ .Wastebasket/ ...


Code:
find "$HOME" -type d -name '.?*' -prune -o -type f -name 'sox' -print

Note the -print is important. Otherwise it defaults to also print the pruned directories!
but you will stuff if it's buried in a places like .cpan .R .conda
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
find command giving incomplete sentence warning guddu_12 Shell Programming and Scripting 3 08-22-2012 10:36 AM
Jumpstart -- Warning: Could not find matching rule in rules.ok christr Solaris 0 09-18-2011 07:07 AM



All times are GMT -4. The time now is 02:54 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.