Home > Software design >  How to use Linux watch against a command piping to sed
How to use Linux watch against a command piping to sed

Time:06-22

When I perform this command:

ip -s link show enp65s0f0 | sed -n '/    vf 4/,$p'

I get this output

    vf 4 MAC 00:00:00:00:00:00, vlan 3932, spoof checking off, link-state auto, trust off, query_rss off
    RX: bytes  packets  mcast   bcast
    3835259656164 3452586352 1       1098
    TX: bytes  packets
    3310560630151 3007239043

I want to watch that command, however when I run the following:

watch "ip -s link show enp65s0f0 | sed -n '/    vf 4/,$p'"

I get this error

sed: -e expression #1, char 16: unexpected `,'

Troubleshooting:

  • I tried using escape characters in my sed command like this watch "ip -s link show enp65s0f0 | sed -n '/\ \ \ \ vf\ 4/,$p'", same error.
  • Tried using single quotes around watch command like this watch 'ip -s link show enp65s0f0 | sed -n '/ vf 4/,$p'', I get the error sed: -e expression #1, char 1: unterminated address regex

How can I get watch against my command piping to sed?

CodePudding user response:

you have to escape $ symbol

watch "ip -s link show enp65s0f0 | sed -n '/    vf 4/,\$p'"
  • Related