LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 12-01-2015, 12:00 AM   #1
bastille77
LQ Newbie
 
Registered: Dec 2014
Location: San Jose
Distribution: Mint
Posts: 5

Rep: Reputation: Disabled
Strange behavior of rm command on Linux Mint


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.
 
Old 12-01-2015, 04:25 AM   #2
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Have you made absolutely sure that there is a tab, and not spaces, before rm -f [^m]*[^ch]

Like this:
Code:
clean:
    rm -f [^m]*[^ch]
Viewing this in Vim with :set list yields:
Code:
clean:$
^Irm -f [^m]*[^ch]$
Best regards,
HMW
 
Old 12-01-2015, 07:32 AM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
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.
 
Old 12-01-2015, 02:10 PM   #4
bastille77
LQ Newbie
 
Registered: Dec 2014
Location: San Jose
Distribution: Mint
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by HMW View Post
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.
 
Old 12-01-2015, 05:41 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,780

Rep: Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] /bin/bash command not find, strange behavior of passwd , kworker is dying after start igadoter Linux From Scratch 4 01-27-2015 04:08 AM
[SOLVED] Very strange behavior of graphics in Mint 13 64 aceleron Linux - Laptop and Netbook 33 12-25-2012 05:31 AM
Basic menu.sh fails: strange behavior on echo command. budhax Programming 3 09-05-2008 06:04 PM
Strange Behavior - chown command Ingla Linux - General 8 01-28-2007 04:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration