2 ms·
Note that the suggested: rm $(ls | grep foo) will not work if you have file names that contain spaces. Shell programming is planted thick with landmines like
by lisper 5y ago
Note that the suggested:
rm $(ls | grep foo)
will not work if you have file names that contain spaces.
Shell programming is planted thick with landmines like this.
- ViViDboarder 5y agoThe linked article doesn’t suggest this. They explicitly suggest against it. > Besides the extra ls, the suggestion is bad because it relies on shell's word splitting. This is due to the unquoted $(). It's better to rely on the splitting algorithms in xargs, because they're simpler and more powerful.
- yakubin 5y agoUsing "ls" is also problematic, because it will outright skip large classes of characters.