4 ms·
Nice. I just had to check to see if xargs has a similar feature. It doesn't, though the --no-run-if-empty and --verbose options are both handy. I believe I'v
by dredmorbius 13y ago
Nice. I just had to check to see if xargs has a similar feature. It doesn't, though the --no-run-if-empty and --verbose options are both handy. I believe I've used xargs with "echo <commandlist>" to proof output before committing it.
You can simply re-run that piped to bash (or your shell of choice) to execute commands if you wish (say, if parallel isn't available).
E.g.,
echo foo bar baz | xargs -n1 -t echo ls | bash
... will execute 'ls foo; ls bar; ls baz', while showing the expanded command.
- rcthompson 13y agoYes, you can use echo, but that won't work if the command is something like "ls DIR | wc -l".
- dredmorbius 13y agoDepending on how you want to do your counts or piping, you could run that after the xargs / parallel execution, which would be much more efficient (fewer processes and execs) anyhow.