From English Grammar Today on Cambridge Dictionary
I need something for storing CDs.
I need something to store CD's.
I adapted them a little bit and got
I need a bookshelf for storing books.
I need a bookshelf to store books.
Are both of them grammatically correct and common? Is there any difference in meaning between them?
As per English Grammar Today linked at the beginning, "for storing books" should be correct, as the function of a bookshelf is for storing books.
However, Ngram Viewer shows both are commonly used.
Note: The ELL post I linked tries to distinguish them but gives "a confusing explanation because the distinction itself is confusing".