Command substitution - problem with spaces

I want to use command substitution with a mv operation

mv $(locate filename) /path/to/destination/

however the result from the locate command contains spaces: /path/to/name of file.pdf which has the entire operation fail. How can you make this work?

put the entire substitution inside quotation marks will do this for you

mv "$(locate filename)" /path/to/destination/

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.