I found somehow interesting command do specify disk usage which I am using without actually knowing what does the exclude pattern do. Instead excluding some locations or file names or just globs, the exclude pattern consists of the regular expression '*[0-9]G*'

Complete command is du --exclude='*[0-9]G*' -hax / | grep '[0-9]G\>' but the first exclude parameter and the last grep parameter are a little bit confusing me as I thought on the first that I am excluding the exactly same parameter whih I am grepping later. Any help with these arguments would be appreciated.


'*[0-9]G*' is in fact a glob expression - not a regular expression.

The command excludes input filenames matching '*[0-9]G*', and then greps for du output lines matching '[0-9]G\>' such as would be produced due to the -h (--human-readable) du option - for example

3.3G  /usr/lib
| improve this answer | |
  • Basically, the exclude glob expression will exclude the filenames with the numerical characters in file name and the 'G' acts as a switch for the global search? And the grep will filter just results with the file size larger than 1GB also? I know that the [0-9] is range, but what 'G\>' stands for? – Alan Kis Jun 10 '17 at 20:46
  • Almost - the G is literal in both the du glob expression and the grep regex. The \> in the grep regex is a GNU-specific word boundary – steeldriver Jun 10 '17 at 20:48

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.