I want to cat several files that are to be found using find
.
The file names contain spaces. This is what I have tried:
$ find "/tmp/database" -name "FOO 03-11*"
/tmp/database/01/FOO 03-11.txt
/tmp/database/03/FOO 03-11.txt
/tmp/database/02/FOO 03-11.txt
/tmp/database/05/FOO 03-11.txt
/tmp/database/04/FOO 03-11.txt
$ find "/tmp/database" -name "FOO 03-11*" | sort
/tmp/database/01/FOO 03-11.txt
/tmp/database/02/FOO 03-11.txt
/tmp/database/03/FOO 03-11.txt
/tmp/database/04/FOO 03-11.txt
/tmp/database/05/FOO 03-11.txt
$ find "/tmp/database" -name "FOO 03-11*" | sort | xargs
/tmp/database/01/FOO 03-11.txt /tmp/database/02/FOO 03-11.txt /tmp/database/03/FOO 03-11.txt /tmp/database/04/FOO 03-11.txt /tmp/database/05/FOO 03-11.txt
$ find "/tmp/database" -name "FOO 03-11*" | sort | xargs cat
cat: /tmp/database/01/FOO: No such file or directory
cat: 03-11.txt: No such file or directory
cat: /tmp/database/02/FOO: No such file or directory
cat: 03-11.txt: No such file or directory
cat: /tmp/database/03/FOO: No such file or directory
cat: 03-11.txt: No such file or directory
cat: /tmp/database/04/FOO: No such file or directory
cat: 03-11.txt: No such file or directory
cat: /tmp/database/05/FOO: No such file or directory
cat: 03-11.txt: No such file or directory
I am using /bin/sh
in FreeBSD 12, which is expected to be a POSIX compliant shell.