I'm trying to move newest files from one directory to another directory.  The find command finds the files but not moving them to another directory.  The destination directory exists. $ cd /app/path1/path2 && \    find . -type f -printf %C@ %p\n | sort | tail -n 2 | \    cut -d   -f 2- |xargs -0 mv -t /app/path1/path2/path3error:  mv: cannot stat No such file or directory
Moving latest files from one directory to another
shell script;files;find;timestamps
Your issue is due to the fact that you've taken control of the formatting of the output generated by find, splitting on newlines now, \n. In order to get xargs to process your output when using -0 the output needs to be separated by null characters, \0. Here's an easy way to fix it though:$ find . -type f -printf %C@ %p\n | sort | tail -n 2 | \    cut -d   -f 2- | tr '\n' '\0' | xargs -0 mv -t /app/path1/path2/path3The introduction of the `tr '\n' '\0' command converts the new lines back to nulls.