Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore mv error?

Tags:

makefile

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.

like image 276
Sam Avatar asked Jun 29 '10 18:06

Sam


People also ask

What does mv file do?

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.

Does mv overwrite existing file?

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.

Does mv overwrite Linux?

By default the mv command will overwrite an existing file.

What is mv command Ubuntu?

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.


1 Answers

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 
like image 199
altendky Avatar answered Oct 04 '22 16:10

altendky