I would like to generate a new Xauthority file using xauth with another hostname portion and write it to a different file name (as opposed to ~/.Xauthority where the xauth command typically writes to). [Later on I want to copy this file to another machine with a different hostname. This machine is a container which binds the X socket but does not have the xauth command installed.]UPDATE: xauth extract ~/.newXauthority $DISPLAY does almost what I want except it does not alter the hostname portion.I did not find anything useful in xauth's man page. 
How to replace the hostname portion with xauth (OLD: How to redirect output of xauth command?)
x11;xorg;xauth
There are 2 sorts of hostname entries managed by xauth, local names such as myhost/unix:0 and remote names such as remote:0. The latter are held as ip addresses, but I imagine you are referring to the local names.The hostname part of these are not actually of any significance to X11, but can be used by the xdm tools to distinguish between several local name entries, each with different keys. To change this name simply list the entry you want, take the key at the end of the line, and provide it to the add command with your new hostname:xauth -f ~/.newXauthority add newhostname/unix:0 . $(xauth list $DISPLAY |awk '{print $NF}')This assumes DISPLAY is :0, and you want the same local display number on the new machine.