Or
echo $NUM_PAGES | sudo tee /proc/sys/vm/nr_hugepages
I've always found it odd that there isn't a standard command to write stdin to a file that doesn't also write it to stdout. Or that tee doesn't have an option to supress writing to stdout.
You forgot the "sudo" before "tee"
> write stdin to a file that doesn't also write it to stdout
You mean like "dd of=/path/file" ?