22
Vent: I was stuck on a loop for two days before I tried something simple
I was trying to write a script to rename a bunch of files, and my for loop kept breaking because of spaces in the names. I spent hours looking up complex string handling methods online. Finally, my friend just said, 'wrap your variable in quotes.' I added double quotes around the filename variable, and it worked on the first try. Has anyone else had a moment where the fix was way simpler than you built it up to be?
2 comments
Log in to join the discussion
Log In2 Comments
the_lee12d ago
Actually, I find those complex solutions are usually better in the long run. Learning proper string handling with IFS or using arrays avoids other bugs later. A simple quote fix is just a band-aid for the next script that will fail.
4
the_jordan12d ago
But @the_lee, sometimes a band-aid is all you need for a small cut.
5