Os dois comandos a seguir são usados para contar números inteiros diferentes de zero da segunda coluna no arquivo de texto. Alguém pode explicar a expressão regular em detalhes.
grep -c '^[^,]*,[^0][^,]*,' < myfile.txt
sed '/^[^,]*,0,.*/d' < myfile.txt | sed -n '$='
Responder1
A primeira regex procura qualquer linha contendo o seguinte:
'^ - start of line, followed by
[^,]* - 0 or more non-comma characters, followed by
, - a comma, followed by
[^0] - any single character other than a zero, followed by
[^,]* - 0 or more non-comma characters, followed by
,' - a comma
grep -c conta o número de linhas correspondentes
A segunda regex corresponde
'/ (the start of the regex)
^ - start of line, followed by
[^,]* - 0 or more non-comma characters, followed by
,0, - a comma then a zero then a comma, followed by
.* - 0 or more other characters
/d' (the end of the regex -- delete the lines matching the preceding expression)