Jump to content


VlexoFree Notice

Interviews will be open every Friday starting at 12am PDT and lasting for 24 hours.

- - - - -

Shell command


  • Please log in to reply
4 replies to this topic

#1 Sean Zhu

Sean Zhu

    Advanced Member

  • Pre-Members
  • 51 posts

Posted 29 July 2009 - 09:37 AM

Can anyone help me make a shell script (preferably a one-liner) that removes all .DS_Store (case sensitive is okay) files from my entire (web) home directory?  I want to use this as a cron job.

I tried
locate ~/*.DS_Store | rm -fv
but it doesn't work.  I'm probably using the '|' all wrong.

And yes, I know I can tell Finder to not create .DS_Store files, but still.

Ad Bot


      #2 Jan J

      Jan J

        Advanced Member

      • VlexoFree Support
      • 960 posts

      Posted 29 July 2009 - 11:07 PM

      Please follow this tutorial (to stop Finder from creating .DS_store files on your Network  drives):

      http://support.apple.com/kb/HT1629
      Regards,
      Jan J

      #3 Eli L

      Eli L

        VlexoFree Owner

      • Owner
      • 6,950 posts
      • LocationWashington, USA

      Posted 30 July 2009 - 12:20 AM

      In the directory you want to start from run the following and it will recursively delete all those files. (Works great for removing those .svn folders too :P )

      find . -name .DS_Store -print0 | xargs -0 rm -rf

      Edit:
      This should do the exact same thing (so you have a choice):
      find . -name .DS_Store -exec 'rm -rf {};'

      Posted Image


      Please do not PM me for support (unless its a private matter). Instead, post in the appropriate forum and help will be provided accordingly.
      Helpful links: Terms of Service | Privacy Policy | Wiki - Tutorials & Help | VlexoFree Support |


      #4 Sean Zhu

      Sean Zhu

        Advanced Member

      • Pre-Members
      • 51 posts

      Posted 30 July 2009 - 11:34 AM

      Jan:
      Thanks, but like I said, I'd rather have the server delete the files later (I may use the .DS_Store files temporarily).
      BTW, TinkerTool can change the setting for you.

      Eli:
      Thanks, I will use it.
      How do I know what current directory it starts from?
      Anyway, I can use this, right?
      find ~ -name .DS_Store -print0 | xargs -0 rm -rf
      How would I remove all files beginning with (or containing, if that is easier) ".wysiwygPro_edit_" (those HTML editor files)?

      #5 budswell

      budswell

        Newbie

      • Pre-Members
      • 2 posts

      Posted 06 April 2011 - 09:10 AM

      View PostSean Zhu, on 30 July 2009 - 11:34 AM, said:

      How do I know what current directory it starts from?
      The first parameter to find is the directory. So in this case it starts at ~ which is a shortcut for your home directory.

      View PostSean Zhu, on 30 July 2009 - 11:34 AM, said:

      How would I remove all files beginning with (or containing, if that is easier) ".wysiwygPro_edit_" (those HTML editor files)?
      The -name parameter can include wildcards (make sure you quote it so the * is not expanded by the shell and goes through to the find process itself.
      find $HOME -name ".wysiwygPro_edit_*" -exec rm {} \;





      0 user(s) are reading this topic

      0 members, 0 guests, 0 anonymous users