Goal: I'm trying to create a PHONY target inside my Makefile so that when I run the command "make backup", It will move all the files that end in "~" into the specified backup folder.
Here is my code currently, and I'll explain the problem after: C++ Syntax (Toggle Plain Text)
.PHONY: backup backup: @mkdir -p ./backup/include #make folder (don't complain if it already exists) @mkdir -p ./backup/src #make folder (don't complain if it already exists) @mv -fu *.h~ ./backup/include #move header file backups into desired folder @mv -fu *.cpp~ ./backup/src #move source file backups into desired folder
Problem: This works great, BUT ONLY if a file ".h~" and ".cpp~" file already exist in Makefile's current directory. I would like this target to move the files if it can, and just be quiet if there are no files to move..
Error Message: mv: cannot stat `*.h~': No such file or directory
*I'm on linux(ubuntu) and so my shell is "bash"
Appreciate the help, I’ve been stuck on this all night trying all kinds of commands from if statements to the "find" command. Just thought I’d finally ask for some assistance