Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to use Linux watch against a command piping to sed

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>Solution :

you have to escape $ symbol

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading