2

This question already has an answer here:

If we have a dir/file setup like the following

var
  |-->usr
  |    |-FileA
  |    |-FileB
  |    |-FileC
  |    |-FileD

How can I move FileA and FileD without specifying the path twice like in the following cmd?

mv /var/usr/FileA /var/usr/FileB /home

marked as duplicate by don_crissti, Anthon, mikeserv, Hauke Laging, jimmij Dec 19 '14 at 19:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

5

Try doing this :

mv /var/usr/{FileA,FileB} /home

or :

( cd /var/usr/ && mv FileA FileB /home )

The later one use a subshell to return to the previous PATH.

Check brace expansion

2

You could just do:

mv /va[r]/usr/File[AB] /home

And possibly even...

mv /va[r]/usr/File[AB] /home
  • What's the point of the brackets around [r]? – Noumenon Dec 23 '16 at 14:49
  • 1
    @noumenon - they expand the known /var/ path first so the stderr is more easy to test. i did an answer on it somewhere here that made more sense before - especially where * is used - but its not especially useful without variables. basically, even if you insert variables somewhere in the path, a filename that exists will always evaluate to /var/... whereas any broken or inaccessible pathname will work out to /va[r]/... – mikeserv Dec 31 '16 at 22:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.