Q:

Bash: wrong pipe output when using "sudo sh -c"

I have a pipe of commands and I use "sudo sh -c" for getting sudo permission throughout the whole pipe commands.
The problem that I am facing is that commands like awk have different behaviour when "sudo sh -c" is used.
In particular,

sudo wc -c Mybib.bin |sudo awk '{print $1;}'

gives 1509644
while

sudo sh -c "wc -c Mybib.bin |awk '{print $1;}'"

gives 1509644 Mybib.bin
So, in the second case looks like the awk command is not invoked at all.
Thanks for any help.

A:

It is, but the double quotes are allowing the $1 to be replaced before invocation, resulting in {print ;}.
sudo sh -c "wc -c Mybib.bin |awk '"'{print $1;}'"'"

Also...
sudo sh -c "wc -c < Mybib.bin"

