You could use your shell's text substitution capabilities. In bash
, you could use a beast like:
mv blob/a_long_directory_name/c/xx !#:$:gs^c/xx^evenmore/yy
To break it down:
!#
is the current line typed so far
:$
asks to pick the last word (replace with a number n
to pick n
'th word) of the string under consideration (!#
in this case). The last word of the line typed so far would be the previous word.
:gs^xx^yy
does global (g
) textual substitution (s
) on the resulting word, replacing 'xx' with 'yy'. ^
is just a delimiter for the s
command to allow using /
in your patterns.
This method is slightly more general as it lets you replace any part of the path ('xx') with any other word ('yy').
Finally, like with any history manipulation, it's good to have appropriate shell options set (e.g. in ~/.bashrc
). In this case
shopt -s histverify
will display the edited line after you press return, so you can still edit it and check for errors.
Why you'd use a construct like that I'm not sure, but it works in this case.