LINUX FUNDAMENTALS - File Descriptors and Redirections

hi, I am new to all of this and I am stuck on a very simple command :wink:
I want to find how many total packages are installed on the remote machine.
I have tried
dpkg -l | wc -l
dpkg --get-selections | grep install | wc -l
apt list | wc -l

Nothing from above is correct and every single of them has another result.
Has anyone an idea what’s going wrong?

playing around with grep piping I’ve got it.

Type your comment> @Numenorean said:

playing around with grep piping I’ve got it.

Can you tell me what command did you use?

This one did it for me
dpkg -l | grep -c '^ii'

More info here:

Hi, i have a question to this command.

I still tried first apt list --installed | wc -l and i received the result with the command with number minus 1.
Can somebody explain me, why?
Thank you in advance.

Hello there,

i had the same question with apt list --installed | wc -l.
wc -l does count every single line of the output and apt list --installed first line is just informational.
With the use of grep you can filter out the informational line.