This question is similar to one I asked recently, but the answers to that question, for the most part, do not extend to this one, AFAICT. The main difference between the two questions is that the earlier one was about copying while this one is about moving. Also, that earlier question was unnecessarily specific by referring to the relative path to a file. In this question I've removed this overspecificity.
I find myself doing this often enough that I wonder if there's a standard Unix way to do it:
% mkdir -p /TARGETDIR/relative/path/to
% mv ./relative/path/to/x /TARGETDIR/relative/path/to
In other words, I don't want to just move somefile
to /TARGETDIR
, but actually I want to "move" (so-to-speak) its entire relative path.
I know that I can write a shell function or a script to achieve the same effect, but I'd like to know if there already exists a way to do this with a single command?