Skip to main content
12 events
when toggle format what by license comment
Apr 13, 2017 at 12:36 history edited CommunityBot
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
May 20, 2016 at 10:53 history edited Hastur CC BY-SA 3.0
Added some comment
May 19, 2016 at 16:04 history edited Stéphane Chazelas CC BY-SA 3.0
added 62 characters in body
May 19, 2016 at 15:55 comment added Hastur @StéphaneChazelas Thanks, for prune I often risk to remain closed in my little gnu world... but even more for the DoS, I didn't think about it.
May 19, 2016 at 15:47 history edited Hastur CC BY-SA 3.0
Fixed vulnerability and increased compatibility
May 19, 2016 at 15:26 comment added Stéphane Chazelas You'd need find ./*.png -prune -exec... or you'd have problems with filenames starting with - (and files of type directory, note that -maxdepth is not portable)
May 19, 2016 at 15:25 comment added Stéphane Chazelas printf "${f%.png}\n" is wrong. The first argument is the format, you shouldn't use variable data in there. Can even be seens as a DoS vulnerability (try with a %1000000000s.png file for instance).
May 19, 2016 at 14:33 comment added user60101 Re-read the wiki again. I still think you need to pipe in your example, since that's what's being discussed here. And for the majority of modern versions of ls there is no issue whatsoever when the output is piped or redirected, but as mentioned in wiki it may not work for all. Most will only insert the ? in place of special characters when the output is sent to terminal. i.e. Do echo *.png | od -c and ls *.png | od -c. The newline issue is not an issue with ls, it's an issue with any command that doesn't null terminate across both sides of the pipe.
May 19, 2016 at 14:31 history edited Hastur CC BY-SA 3.0
added 226 characters in body
May 19, 2016 at 8:58 comment added Hastur Dear @BroSlow, when I wrote the answer above I tried 13 (all) of the other variants present in that moment, by command line, in a script, launched as argument of a shell invocation. Please do the same and tell me if they behave in the way you expect. I did my tests with bash 4.3.11, dash 0.5.7-4, zsh (when needed) 5.0.2. Feel you free to read this post that adds something more. I agree about the note of piping the output of find, for this I expressly suggested -exec, and I wrote in the title. :-).
May 19, 2016 at 2:09 comment added user60101 Also the results of your find command are a bit variable (for example if there is a directory called files.png)
May 19, 2016 at 0:30 history answered Hastur CC BY-SA 3.0