So, like, guise, I have this bash script that `find`s all of the images in a directory and performs a task on them, but shit goes down when the path has spaces in it.
Like, say I have a path ~/blah.jpg, it performs the task on ~/blah.jpg, but if I have shit like ~/blah 2.jpg, it tries to do it to ~/blah and 2.jpg, which sucks total ass.
>>6
This is why I always use superfluous apostrophe's.
Name:
Anonymous2009-11-28 17:29
Shit, I'm fucking stupid.
It's this fucking for loop I've got that's fucking with the spaces.
I've got like
for i in `find -name ".jpg" -o -name "*.png"`
And it's reiterating for the spaces. Can I make it only do it for the newlines instead of just any whitespace? The whole thing is I'm not good at bash and its a nigger when it comes to strings anyways.
>>7
Yeah, I have no idea why I did that >>8
I don't think it can check for names like that, but you could use -print0 and a pipe or something I don't actually know or care
And of course, if you've been following along for a week or two, you know that this (BING!) is a Useless and Dangerous Use of Backticks!
Remember, most cases where you have: for f in `command ...`; do
...
done
you should rewrite it as: command ... |
while read f; do
...
done
and in some cases, such as this one, you can use xargs as in: find ... -print0 | xargs -0 foo