I'd like to create symbolic links for multiple books searched from running find
command.
Firstly, I collect all the JS books
find ~ -type f -iregex '.*javascript.*\.pdf' > js_books.md 2>/dev/null
It returns 35 books
../Coding/Books/HTML_Collections/Freeman E.T., Robson E. - Head First HTML5. Programming Building Web Apps with JavaScript - 2011.pdf
../Coding/Books/HTML_Collections/Learning Web Design - A Beginner's Guide to HTML, CSS, JavaScript, and Web Graphics - Jennifer Niederst Robbins - 4th Edition - August 2012.pdf
..
Additionally to copy them to directory js_books
mkdir js_books
find ~ -type f -iregex '.*javascript.*\.pdf' -print0 -exec cp '{}' js_books
It works, however, multiple copies consume lots of disk space.
So I delete the books and try to make symbolic link within.
find ~ -type f -iregex '.*javascript.*\.pdf' -print0 -exec ln -s '{}' js_books/'{}' \;
It returns nothing in dir js_books.
How to work out such a problem?
Best Answer
You can loose the
-print0
primary and the strong quotes around{}
. I suggest that you use a glob pattern instead of a regex. Something like: