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

I am doing an applescript that is supposed to set the size of an folder to an varible. This is the code so far:

set sizeVar to do shell script "du -skh -m /Users/JS_Admin/Desktop"


"4242   /Users/JS_Admin/Desktop"

The thing is that I only want the size in numbers, no space or directory location.

How do I do that?

share|improve this question
up vote 7 down vote accepted

Specifying both -k and -m does not make sense: either you want 1-Mbyte or 1-Kbyte blocks. Also -h does not make sense in combination with -k and -m. Only the last one -m will be considered

You can use cut to remove anything after the space:

du -sm /Users/JS_Admin/Desktop | cut -f1

With -f you specify which field you need (in this case the first one).

share|improve this answer
Thanks! It worked perfectly! – DevRandom Dec 17 '12 at 11:02

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.