D
D
DarkByte20152018-09-17 16:09:49
linux
DarkByte2015, 2018-09-17 16:09:49

echo result or 0?

This is how I get the file size: du -b file | cut-f1. But if the file suddenly does not exist, then nothing is returned to me, but I want it to return 0. How can I do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Burov, 2018-09-17
@DarkByte2015

(du -bs /path/ 2> /dev/null || echo 0) | cut -f1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question