last day (15 days later) » 

4:13 PM
0
A: How to write a unix command or script to remove files of the same type in all sub-folders under current directory?

seacoderfind . -name "*~" -exec rm {} \; or whatever pattern is needed to match the tmp files.

 
find . -name "*~" -delete
@JRFerguson, Note that -exec $command {} + is a GNU extension. (I don't know about -delete.)
@JRFerguson, Even if others have adopted the extension, it's still not standard. It won't work everywhere.
 
@ikegami -exec ... {} + is posix, though it may not be present in very old implementations.
 
@BroSlow, Old? I've had users on SO complain that their system didn't support +. Not all current systems support it.
 
@ikegami There are definitely older versions which don't support it. But I think most of the time people claim not to have +, they are simply misusing it (i.e. omit {} or don't have it directly preceding the +). It's been in the posix standard since at least 2004, and the modern versions of gnu, freebsd, and solaris find all correctly support it.
 
@BroSlow, you obviously don't know how many people still use Perl 5.8! Your definition of modern is unrealistic or what you consider modern is irrelevant.
 
4:13 PM
@ikegami This seems like a pointless argument. It simply is not a GNU extension and it is standard (complies with the posix standard). It also happens to be supported in the newest version of every major implementation of find (rephrased since you don't like the word modern)
 
@BroSlow, Re "It simply is not a GNU extension", Stil as irrelevant as it was before. Re "It also happens to be supported in the newest version of every major", Still as irrelevant as it was before. I don't know why you're repeating these irrelevant arguments. The -exec $command {} + extension is simply not available on commonly used machines. If it's available on the machine the OP uses, fine, but I'm letting him know his solution isn't portable. Nothing you've said contradicts that, so your comments seem to have indeed been pointless. Would you mind getting rid of this spam?
 
Both me and JRFerguson listed operating systems/find versions on which the extension is available. Your comments on the other hand border on simply repeating some variant of "it's not portable" and simply inaccurate/misleading statements.
If you have some actual operating systems or find versions on which the -exec ... {} + is not supported, by all means list them, otherwise I'm absolutely flabbergasted that a user with 139k rep takes this line when other users point out a mistake he's made.
 
That is indeed my only statement
And nothing you said contradicts it
What mistake did I make?
 
Note that -exec $command {} + is a GNU extension. (I don't know about -delete.)
That being wrong
Even if others have adopted the extension, it's still not standard.
As well as that
 
I acknowledged that others have also included the expansion
 
4:23 PM
Again if you want to claim the majority of operating systems or find versions don't support it, you need evidence
 
But that doesn't change anything
 
which you don't have and have not provided
 
I never used the word majority?!
 
So you define "standard" how?
 
I didn't use the word standard either
wtf?
 
4:24 PM
Ok, you define "portable" how?
It's posix and used by the majority of users
 
A high percentage of the times I recommended find -exec {} + on SO, it was not available to the user.
Yes, and that's totally irrelevant.
 
Like I said, a lot of users will misinterpret the "find: missing argument to `-exec' " error
 
That's not what I said.
If that was relevant, changing to ; wouldn't have fixed the problem
 
Nope
You can put {} anywhere in -exec ... ;
You can't put {} anywhere in -exec ... +
 
Didn't know that, but I always used it at the end
 
4:28 PM
But doesn't mean users necessarily did
Or could have omited + all togeather
 
we're talking about my command
My command didn't work because their find didn't support +. They had to switch to ;
I don't remember what OS they had, but it doesn't really matter. This didn't just happen once.
 
There are obviously "old" versions which don't support it. Including, e.g. the 2004 version of GNU find, but that still doesn't mean it's not standard
 
That could very well be.
I never said the extension didn't make it into the standard since
(I didn't know it had, so that was nice to know, but it didn't affect what I said.)
I gotta go
 
Right, but when we talk about a command being "portable", it's usually in the sense that it's posix defined.
ok, bye
 

last day (15 days later) »