0

I'm trying to run join a bunch of files using the find command.

I have determined that filenames containing spaces are giving me a problem.

The following comand works for files that do not contain any spaces but fails when the filename contains a space.

  find /media/primary/acronis_ntfs/flickr_01/. -type f -name '*.*' | xargs cat > /media/primary/acronis_ntfs/flickr_01.txt

I have tried different commands as well - all with the same results.

  find /media/primary/acronis_ntfs/flickr_01/. -type f | xargs cat > /media/primary/acronis_ntfs/flickr_01.txt

If I go directly into the folder and run

  cat * > flickr_01.txt

It works - spaces and all.

I'm running ubuntu 16.10.

Any suggestions?

I'm losing my hair over something I thought is simple.

speld_rwong
  • 799
  • 1
  • 12
  • 21
  • see [What should I do when someone answers my question?](https://unix.stackexchange.com/help/someone-answers).. any particular reason you haven't accepted any of your 30 questions asked? – Sundeep Dec 10 '17 at 03:54
  • see also https://unix.stackexchange.com/questions/321697/why-is-looping-over-finds-output-bad-practice for usage of `-exec` option – Sundeep Dec 10 '17 at 03:55

1 Answers1

3

Make find use a NUL as the separator between filenames and tell xargs to look for same:

find .... -print0 | xargs -0 ...
NickD
  • 2,866
  • 1
  • 10
  • 21