0

I have a custom nvidia-smi message where some additional information (e.g., username) is also output underneath the original output of the nvidia-smi message.

I want to feed that output to a tail command so that I only see the bottom part of the message. How should I go about doing that?

Right now I have the following:

alias gpu='watch -n 1 "nvidia-smi | tee /dev/stderr | awk '"'"'/ C / {print \$3}'"'"' | xargs -r ps -up"'

which works fine. But again, it only shows the top portion.

In order to show the bottom portion, I've tried something like:

alias gpu2="watch -n 1 \"nvidia-smi | awk \"/ C / {print \$3}\" | xargs -r ps -up | tail -n $(($LINES - 2))\""

but when I run this command I get the following output:

Every 1.0s: nvidia-smi | awk / C {print } | xargs -r ps -up | tail -n 40

awk: cmd. line:1: /
awk: cmd. line:1:  ^ unexpected newline or end of string

I'm not exactly sure what the problem is and how to interpret the error message. I've tried escaping the slashes but that didn't work.

How should I go about solving this issue? Thanks.

2

0

You must log in to answer this question.

Browse other questions tagged .