Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • This will fail with filenames containing newlines or tabs, so it's not very general. Pasting commands to a shell also feels somewhat iffy, given that there's also a proper solution (in your other answer). Commented Sep 29, 2017 at 20:12
  • Correct: as I said it's not a general solution, but it is a useful trick to have in one's tool belt. "Pasting commands" - did you mean "Piping commands"? If so, I disagree that it is iffy: it is actually much safer than a shell script, because I can look at the commands before I execute them. Commented Sep 29, 2017 at 20:16
  • yep, I meant piping like that. You'd need to be very careful to double check the commands, otherwise you might end up running commands from the filenames. Which would not happen with a shell script that does its job properly. Commented Sep 29, 2017 at 20:20
  • I find the trick valuable in "irregular" situations where a shell script is harder to write. If it's a one-off, why bother writing the script? You'd have to write it, test it, debug it and after all this trouble throw it away. Instead, I can write a file (or better yet write a script that writes the file) that contains exactly the commands I need and pipe it into the shell - and then throw it away. Commented Sep 29, 2017 at 20:26