How do I properly quote this bash pipeline for watch?

前端 未结 2 880
孤城傲影
孤城傲影 2021-01-20 06:37

I\'ve built up this pipeline:

echo \"scale=2;$(cat io | grep wchar | awk \'{print $2}\')/(1024^3)\" | bc

Now I\'m trying to watch

2条回答
  •  自闭症患者
    2021-01-20 07:05

    Try having watch invoke the shell:

    watch sh -c 'echo "scale=2;$(awk '/wchar/ {print $2}' io)/(1024^3)" | bc'
    

    This is similar to having it invoke a script but without needing a separate file.

提交回复
热议问题