Command fails via 'bash

This question already has an answer here:

  • How to escape single quotes within single quoted strings? 19 answers

  • You cannot escape single quotes inside single quotes that way. It does not work.

    Your command is being seen as

    sudo lspci -vvv | awk /System peripheral/ {portn=$1} /Status:/ {split($3,a,"M");printf "%sn",a[1]}
    

    which fails.

    To place a single quote inside a single quoted string you need to use ''' .

    So your command becomes:

    bash -c 'sudo lspci -vvv | awk '''/System peripheral/ {portn=$1} /Status:/ {split($3,a,"M");printf "%sn",a[1]}''
    
    链接地址: http://www.djcxy.com/p/57138.html

    上一篇: 问题与div.innerHTML函数中的撇号

    下一篇: 命令通过'bash失败