5

I am using Solaris. I have several directories with the following names:

saa_first.data
saa_second.data
saa_third.data

I want to remove these directories along with its content, so I use:

rm -fr saa*

What I get is the following questions:

rm: examine files in directory saa_first.data (yes/no)? n
rm: examine files in directory saa_second.data (yes/no)? n
rm: examine files in directory saa_third.data (yes/no)? n

I don't get any error, but the directories are not deleted. What gives?

Here is my Solaris info:

$ cat /etc/release
                  Solaris 10 10/08 s10s_u6wos_07b SPARC
       Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
                    Use is subject to license terms.
                        Assembled 27 October 2008

UPDATE:

It works after I use the following command:

/usr/xpg4/bin/rm -fr saa*

I am still interested with the explanation why it didn't work with /usr/bin/rm though.

8

You will most likely find that you have rm aliased to rm -i. If you had answered y to the question you would then have been asked to authorise the deletion of each file in each directory.

$ alias rm
alias rm='rm -i'

$ rm -r tmp1
rm: examine files in directory tmp1 (yes/no) y
rm: remove tmp1/1 (yes/no) y
rm: remove tmp1/2 (yes/no) y
rm: remove tmp1: (yes/no) y

You can temporarily remove the alias with the unalias command. If you want to permanently remove it you will have to find where in your shell initialisation files it is defined and remove it. Had you used the full path /usr/bin/rm it would have worked the same as /usr/xpg4/bin/rm

  • You are right, there is an alias to rm -i as you predicted. Who the bloody fool did this to me?.. I wasted 1 hour for this. – Rosdi Jan 18 '11 at 10:45
  • 1
    \rm would also work to override the alias. Note to future readers: It's a bad idea to alias rm to rm -i. If you get in the habit of relying on this it will bite you hard one of these days when you assume that the safety net is there and it's not. – Dennis Williamson Jan 18 '11 at 15:03
0

I reckon this is due to files not being removed from those directories, henceforth the directories can't be deleted.

A more controlling way of doing this would be the following

find . -name "saa*" -maxdepth 1 -exec rm {} \;
find . -name "saa*" -maxdepth 1 -exec rmdir {} \;

This will make sure that it deletes files from those directories first, and then once the directories are empty it'll remove the directories themselves.

0

Isn't there a -d option on Solaris? On BSD, I would 'rm -dfr directory'. Check your man page :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.