I'm making a Makefile that moves an output file (foo.o
) to a different directory (baz
).
The output file moves as desired to the directory. However since make won't recompile the output file if I type make
again, mv
gets an error when it tries to move the non-existent empty file to the directory baz
.
So this is what I have defined in my rule make all
after all compilation:
-test -e "foo.o" || mv -f foo.o ../baz
Unfortunately, I'm still getting errors.
Use the mv command to move files and directories from one directory to another or to rename a file or directory. If you move a file or directory to a new directory without specifying a new name, it retains its original name.
Attention: The mv command can overwrite many existing files unless you specify the -i flag. The -i flag prompts you to confirm before it overwrites a file. If both the -f and -i flags are specified in combination, the last flag specified takes precedence.
By default the mv command will overwrite an existing file.
The mv command is one of the basic Linux commands that is used to move files and directories from one location to another. It is also used to rename files and directories. The mv command is by default available on all Linux distributions.
Errors in Recipes (from TFM)
To ignore errors in a recipe line, write a
-
at the beginning of the line's text (after the initial tab).
So the target would be something like:
moveit: -mv foo.o ../baz
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With