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.

Not the answer you're looking for? Browse other questions tagged .