Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've the following rm command in a makefile for a C program.
clean:
rm -f [^m]*[^ch]
As I understand this should delete all files which doesn't start with the letter 'm' or end with the letters 'c' or 'h'.
The strange thing is that the above command works fine when I run it on a CentOS system, the files which I want to delete are deleted.
But when I run the exact same command on a Debian-based system (Mint), it doesn't work, the object files are not deleted.
I've the same version of make (3.81) installed on both systems.
Can someone explain what is going on here?
After tinkering with the command further, I found out something even weirder. On Mint, when I run the rm as a standalone command, it deletes the files which I want. But when I run the command through make in the following way:
$ make clean
The command doesn't work, as far as I could tell no files are deleted.
On CentOS however, everything works as they should.
Now I'm really confused.
Last edited by bastille77; 12-01-2015 at 12:45 AM.
This is a very odd thing to code as part of your Makefile clean method.
Firstly, all targets are generated and known, correct? So you can remove $(OBJS) and or $(TARGET).
Using some oddball wildcard rm statement is risky. Just my humble opinion there. I have no real problem saying something like "rm -f *.o", I just think you're overdoing it, but do realize that it's your choice.
Have you made absolutely sure that there is a tab, and not spaces, before rm -f [^m]*[^ch]
There is a tab before rm in the actual makefile(just double checked). For some reason I couldn't get tab to work when typing texts in this forum, hence the lack of indentation in the example.
As mentioned before, the odd thing is that "make clean" works on my CentOS machine but doesn't work under Mint. Still have no clue why it is exhibiting such behavior.
Quote:
Originally Posted by rtmistler
Using some oddball wildcard rm statement is risky. Just my humble opinion there.
I do realize using "rm $(objects)" will work just well in my case. But I would still love to figure out what is going on with my overkill rm command.
Last edited by bastille77; 12-01-2015 at 02:22 PM.
You could do an strace on the make process and see what it is trying to do. I'm wondering whether make hands off those pathname expansions to a shell or does them itself. If the latter, there could certainly be differences between the two versions.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.