On my lubuntu 24.04 I have a small / filesystem so I check from time to time if enough space is free.
For this I use
sudo du -xh -d 3 / | sort -h -r | egrep -v '*M|*K'
grep: warning: * at start of expression
grep: warning: * at start of expression
27G /
12G /var
10G /var/cache
9,8G /var/cache/apt
9,6G /usr
6,0G /usr/lib
5,6G /boot
2,8G /boot/ubuntu-20.10
2,5G /boot/bullseye
2,2G /usr/share
1,9G /usr/lib/x86_64-linux-gnu
1,7G /var/lib
This is not a question where my space is gone I can not figure out what the warning is meaning and how I can avoid it.
env | grep -i shell
SHELL=/bin/bash
egrep
expects a regular expression, but you gave it*M|*K
. There is an asterisk at the beginning of both the alternative expressions. The asterisk has a special meaning in regular expressions: it says "the previous thing is repeated zero or more times". But here, there's no previous thing to be repeated. Hence the warning.Are you maybe trying to use a search pattern in the globbing syntax, using
*
as a wildcard character?grep
doesn't work like this. Withgrep
, you use regular expressions. There
ingrep
actually stands for "regular expression".In regular expressions,
*
is a quantifier. A quantifier specifies how often the preceeding element should be recognized. For example, to recognize "at least one 'a', followed by exactly one 'b'", you could use the patterna+b
.In your pattern, the quantifier
*
is at the very beginning, so there is no preceeding element to specify a number for. You're basically saying, "look for zero or more instances of, and then exactly one 'M'". That doesn't really work ;) A*
at the very beginning of a regular expression is actually supposed to produce an undefined result by the POSIX standard.Fortunately, you don't have to specify the whole occurrence in your search pattern. So you could just search for "exactly one M or exactly one K, followed by a whitespace character" like this
If this exact pattern happens to appear in your file paths, those occurrences would be found as well. You could make the regular expression more complex to exclude those false positives, but that's beyond the scope of this answer.