I want to use find to find some files, and return all files as a single line (without newline characters), and a custom delimiter between the files.

So for example the result for three files would be


instead of


Is there any way of achieving this using standard unix tools in combination with find?


You can use :

find . -type f -printf '%p::' | sed 's/::$/\n/'
  • The -printf predicate of find will print the file names in a single line delimited by :: and then sed will substitute the last :: with a newline.

Example :

$ find . -type f -printf '%p\n'

$ find . -type f -printf '%p::' | sed 's/::$/\n/'
| improve this answer | |
  • 1
    For the record: availability of the expression -printf. Other finds will output something like: find: -printf: unknown option or find: unrecognized: -printf... – don_crissti Jul 6 '15 at 10:07
  • 1
    On macOS, you can install the GNU version of find using Homebrew: brew install findutils and use gfind instead of find. – Frederic Dec 21 '18 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.