Hacker News new | past | comments | ask | show | jobs | submit login

xargs is fucked up when it comes to handling spaces in filenames and such. In fact, this is pretty much the only reason I use GNU parallel — I rarely need to actually run stuff in parallel (but it usually doesn't hurt either), but I need to do something pretty complicated (list | grep | sort | uniq | feed it to feh / whatever) over multiple arguments, without having to worry if these arguments contain spaces, quotes, unicode symbols, etc.



Protip: for "strange" characters, see the -0 argument to xargs. If the file list comes from find, see the -print0 argument there.

    find -print0 | xargs -0 -n1 echo

    echo -n "file '#1'\0file '#2'\0" | xargs -0 -n1 -I{} echo "the file is \"{}\", ok?"


Oh yeah, great I idea. Now insert sorting somewhere between the pipes and use at least one filename with '"' character. Good luck with your xargs. parallel handles all this automatically, you don't even have to know there might be any problems with escaping here.


Thanks - I will take a closer look at parallel.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: