-8

As I am new to unix, can somebody tell me how to move a file please. I got an error message as missing destination file operand.

mv dog/mammals/shape

enter image description here

Stewart
  • 13,677

1 Answers1

4

mv takes two arguments: SOURCE and DEST where SOURCE is the file you want to move in its original location, and DEST is where you want to move it.

Arguments are space-delimited. You provided a command which only gives one argument:

mv dog/mammals/shape

This says move the file/dir called shape from dog/mammals/ to somewhere that isn't defined.

The correct answer is:

mv animals/mammals/dog shape/

You can think of this as: "move file animals/mammals/dog to shape/"

Stewart
  • 13,677
  • I have tried what you said sir but still the file is not moved.And the error message is No such directory .Can you please tell me sir. – gracesam Sep 02 '20 at 16:40
  • In that case, either animals/mammals/dog or shape/ doesn't exist. Create the former with mkdir -p animals/mammals && touch animals/mammals/dog or create the latter with mkdir shape. – Stewart Sep 02 '20 at 18:54
  • $ mkdir -p mydir/{colors,shape,animals} $ mkdir -p mydir/colors/{basic,blended} $ touch mydir/colors/basic/{red,blue,green} $ touch mydir/colors/blended/{yellow,orange,pink} $ touch mydir/shape/{circle,square,cube} $ mkdir -p mydir/animals/{mammals,reptiles} $ touch mydir/animals/mammals/{platypus,bat,dog} $ touch mydir/animals/reptiles/{snakes,crocodile,lizard}

    $ mv mydir/animals/mammals/dog mydir/shape/

    – gracesam Sep 03 '20 at 05:33