Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a simple terminal command maybe to delete all actual data, all files but leave all the directories there? Including packages (.app) as directories?

-- You don't need to read this: The reason why is on my iPod Touch, whenever I ssh to /private/var/mobile/Applications to get an icon or something to change for a theme, I have to look through every folder to find the application, since they're all in their unique identifier folders (e.g. 2C053638-26FE-42DD-A235-30FCBA59E623), its impossible to find it. So I copied the Applications folder to my desktop, so I could spotlight search for the application name in it and then the folder that its in would be the unique id folder on the iPod, so having it sorted the same I could easily find it.

share|improve this question
up vote 8 down vote accepted

Are you wanting to delete just the files from the current directory, or files from sub-directories too? For the latter this would work under most unix-a-like environments

find . -type f -print0 | xargs -0 rm -f

or if you know there are no files or directories with spaces in their names you can simplify a little with

find . -type f | xargs rm -f

I'm not an Apple user so I know little of the .app directories of which you speak, but you should be able to avoid touching them by adding grep between find and xargs like

find . -type f | grep -v \.app | xargs rm -f

Replace rm -f with ls or ls -l in all the above to get a list of what would be deleted instead of actually performing the delete.

share|improve this answer
mmm good ol' find | xargs – Roy Rico Oct 7 '09 at 23:48
OS X has a modern enough version of find to support "find . -type f -exec rm -rf {} + " -- note the "+" instead of the "\;" after the -exec. This mimics the xargs part within find's exec – Doug Harris Oct 8 '09 at 3:30
no need for xargs or -exec at all, just use "find . -type f -delete" – akira Oct 8 '09 at 5:26
I tend to stick to the trinity of find+grep+xargs, mainly out of habit. Way-back-when, in years past, you would come across versions of find that didn't support the more "advanced" options or didn't implement them the same way, though these days find is nearly always GNU's find (or something that mimics it accurately) but old habits die hard. – David Spillett Oct 8 '09 at 11:06
I used find . -type f -delete worked great, now in get info the top folder takes up Zero kb, and app bundles are still there. Thanks! – Mk12 Oct 9 '09 at 0:40

Find can delete as well:

$ find . -type f -exec rm {} \;

BE CAREFUL: this command means business--it delete all files starting from the current directory without asking.

share|improve this answer
"find . -type f -delete" would be THE delete command of find. – akira Oct 8 '09 at 5:25
I learn something new every day. Thank you Akira. – Hai Vu Oct 9 '09 at 6:34

open your terminal application

(1) cd {path of the iTouch content}

  for example:  cd /Users/Mike/Desktop/myTouch

(2) then recurse through the directories and remove content.

  find {directory} -type f | tee output

  for i in `grep -v .app output`
   echo ${i}; rm ${i}

for example,

find /Users/Mike/Documents/myTouch/ -type f | tee output

for file in `grep -v .app output`
 echo ${file}
 rm ${file}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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