Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to delete a directory?

I would like to know how to delete a directory on my MacBook. I have tried several methods such as moving it to the Trash -> Empty Trash, via the command sudo rm -rf, restarting the computer in diagnostic mode and checking the disk with Disk Utility.


These are some of the commands used so far for trying to delete the directory:


rm


    $ sudo rm -rf delete_dir
      rm: delete_dir/npm/cache/content-v2/sha512/18/del: Directory not empty
      rm: delete_dir/npm/cache/content-v2/sha512/18: Directory not empty
      rm: delete_dir/npm/cache/content-v2/sha512: Directory not empty
      rm: delete_dir/npm/cache/content-v2: Directory not empty
      rm: delete_dir/npm/cache: Directory not empty
      rm: delete_dir/npm: Directory not empty
      rm: delete_dir: Directory not empty


lsof


    $ lsof | grep delete_dir
    $ 


rm via inode number


    $ cd delete_dir/npm/cache/content-v2/sha512/18/
    $ ls -i del/..
      1376336 del/
    $ find . -inum 1376336 -exec rm -rfi {} \;
      examine files in directory ./del? y
      remove ./del? y
      rm: ./del: Directory not empty


Via Restart and Recovery Mode


    $ mv delete_dir/npm/cache/content-v2/sha512/18/del /tmp/delete_dir 
    $ rm -rf /tmp/delete_dir
      rm: delete_dir: Directory not empty
    $ cd /tmp/delete_dir
    $ ls -lhia
    total 0
        1376336 drwxrwxr-x  3 root    staff    96B Jul 14 11:11 ./
    12906575931 drwx------  3 jordan  staff    96B Jul 14 20:27 ../


Thank you.

Posted on Jul 15, 2019 12:55 PM

Reply

Similar questions

There are no replies.

How to delete a directory?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.