1

So my disk is full, I am trying to grep for all the files larger than 1G. I tried searching for the word Sort in the man page of DU, but found nothing.

du -h . | grep -E "^\d*\.\d*G"

and also this.

du -h . | grep -E "^\d*?\.\d*?G"

I tried both of these command, but it is missing all the 1Gb files. My Regex-Fu is a bit rusty these days, so I figured I might just ask in stack-exchange.

  • you can just do with du -h -t 1G – αғsнιη Oct 19 '18 at 14:27
  • 1
    and what if you had a Terabyte-sized file? I think you'd have an easier time if you didn't tell du to make the sizes human-readable, since you're now asking the computer to read the sizes. – Jeff Schaller Oct 19 '18 at 16:27
  • @JeffSchaller I have exactly 44GB on that drive :) – Aditya Oct 19 '18 at 16:28
  • I see your point though. – Aditya Oct 19 '18 at 16:30
  • Another handy tool for interactive disk space digging is ncdu – Criggie Apr 18 at 21:26
4

Use find:

find . -type f -size +1G
  • Right .. but what was wrong with my regex? – Aditya Oct 19 '18 at 14:10
  • Extended Regex doesn't know about \d, use PCRE (grep -P) or use [0-9]. Note that if \. doesn't work for some languages. – pLumo Oct 19 '18 at 14:16
  • @aditya your regex was incorrect. As to why...? Ask a regex expert. You wanted help on solving a problem (finding files > 1G). perlmonks.org/index.pl?node_id=542341 – 0xSheepdog Oct 19 '18 at 16:34
  • Easy there now, I cannot accept answers with in 10 minutes of posting a question. I never said that I have an issue with his answer. I was just curious to know why my solution didn't work. – Aditya Oct 19 '18 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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