11

I'm trying to get the size of a folder an application is currently writing to. If I run the du command it sometimes fails with the error:

du: cannot access `/a/b/a.txt': No such file or directory

because the application deleted the file while du was processing. How can I tell it to ignore such errors?

2 Answers 2

8

You can filter standard error using grep, without losing (possibly important) other error messages. In bash:

du 2> >(grep -v '^du: cannot \(access\|read\)' >&2)
2

try like this

     du -sh /home/dir 2> /dev/null | cut -f1

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.