Results 1 to 3 of 3

Thread: how to delete folders called * without deleting other folders?

  1. #1
    Join Date
    Oct 2008
    Location
    /usr/bin/
    Beans
    493
    Distro
    Ubuntu

    how to delete folders called * without deleting other folders?

    this may look unusual but I have a lot of folders called * , I want to recursively delete them all but if I use rm -rf * command it deletes all the other folders too

    for example

    [~]# mkdir 001
    [~]# cd 001
    [~/001]# mkdir *
    [~/001]# mkdir 001
    [~/001]# ls
    ./ ../ */ 001/
    [~/001]# rm -rf *
    [~/001]# ls
    ./ ../

    how can I only delete the folders called *? and I need to do it recursively.

    thanks
    Last edited by sohlinux; April 18th, 2013 at 01:36 PM.

  2. #2
    Join Date
    Nov 2008
    Location
    S.H.I.E.L.D. 6-1-6
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: how to delete folders called * without deleting other folders?

    Quote Originally Posted by sohlinux View Post
    this may look unusual but I have a lot of folders called * , I want to recursively delete them all but if I use rm -rf * command it deletes all the other folders too

    for example

    [~]# mkdir 001
    [~]# cd 001
    [~/001]# mkdir *
    [~/001]# mkdir 001
    [~/001]# ls
    ./ ../ */ 001/
    [~/001]# rm -rf *
    [~/001]# ls
    ./ ../

    how can I only delete the folders called *? and I need to do it recursively.

    thanks
    escape using double quotes
    i.e. like
    Code:
    rm -rf "*"
    Don't waste your energy trying to change opinions ... Do your thing, and don't care if they like it.

  3. #3
    Join Date
    Oct 2008
    Location
    /usr/bin/
    Beans
    493
    Distro
    Ubuntu

    Re: how to delete folders called * without deleting other folders?

    Quote Originally Posted by sandyd View Post
    escape using double quotes
    i.e. like
    Code:
    rm -rf "*"
    thanks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •