Replacing new lines with nulls in bash

If you have a list of file names separated by new lines, and you want to turn it into a list of file names separated by null characters, for instance for use as input to xargs, then you can use the tr command, like this:

  $ cat /path/to/new-lines | tr '\n' '\0' > /path/to/null-separated

I found a whole article on various ways to replace text on *nix: rmnl — remove new line characters with tr, awk, perl, sed or c/c++.