Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My problem was that I had a directory with probably 200+ subdirectories each one, and the files and subdirectories below them, had a couple of spaces in the name. I typically use

    for f in ‘ls’; 
For operations like that but it was obviously built on windows (but I run steam on Ubuntu) and I never interact with windows so tbh I had never thought of this problem before.


The GNU way for handling files that have inconvenient characters in their names is:

    find ... -print0 | xargs -0 ...
It makes all the problems go away.


Also you can use readarray to store the found filenames in a bash array (to use with a for loop).




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

Search: