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.
It is, but the double quotes are allowing the
$1to be replaced before invocation, resulting in{print ;}.Also…