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

Sorry, what do you think

    vim $(grep -lr foo | xargs)
is doing? Assuming a missing directory after the `foo' why can't it just be

    vim $(grep -lr foo .)
I don't see that xargs's default behaviour is adding anything.

For

    find . -name foo_fn exec sed -i s/foo_fn/bar_fn/g '{}' \;
you may find -exec's + of use. The above has the fork/execve overhead for each file found.

    find -name '*.[ch]' -exec sed -i 's/\<foo\>/bar/g' {} +


You are correct on both counts regarding the vim and grep example - I guess I just assumed I would have to have all the files on a single line before handing them off to vim.

Thanks for the suggestion about -exec +; I will have to remember it in the future.


Backticks, ``, and $(), use IFS to parse the command's output into words which then become the $()'s replacement and IFS normally contains \n.




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

Search: