Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Disregard spaces, aquire full paths [bash]

Name: Anonymous 2009-11-28 16:25

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.

How can I fix dat shit, my /prog/ niggas?

Inb4 "Herp derp spaces in unix".

Name: Anonymous 2009-11-28 19:35

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

Just another Useless Use of /prog/,

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List