Reputation: 23
I have a text file containing .M4B filenames (including source path). The file names contain spaces and quotes like:
/file/source/Ender's Game.m4b
/file/source/Ender's Shadow.m4b
/file/source/Speaker for the Dead.m4b
I'm trying to pipe the file contents to cp the audiobooks to the same destination using the xargs command:
cat /path/to/file/filenames.txt | xargs cp {} /destination/folder/ \ ;
The first time i ran the command it returned xargs: unterminated quote
I then put quotes around the filenames /file/source/"Ender's Game.m4b" and ran the command and it returned: cp: /file/source/Ender's Game.m4b is not a directory
Using zsh and macOS Ventura 13.0.1
Upvotes: 0
Views: 176
Reputation: 3020
A possible approach to overcome quotes' pain could be converting newlines to ascii nuls, then ab-using xargs -0
:
cat /path/to/file/filenames.txt | tr '\n' '\000' | xargs -0 -I{} cp {} /destination/folder/
Upvotes: 1