0

I am trying to get the monitor name of my secondary monitors using xrandr -q. I am able to get the primary using xrandr -q | awk '/primary/{print $1}', but I also want to get the secondary monitors. I have tried xrandr -q | awk '/ connected/{print $1}', but that also includes the primary. Is there a way that I can do a combo of these two commands (but the first in reverse), where it will show all with "connected" and exclude the one with "primary".

  • 2
    Hello and welcome to StackOverflow. Please edit your question to include the output of xrandr -q. – Panki Sep 11 '18 at 12:32
3

Yes, in awk you can combine conditions using logical operators && || !

Ex.

xrandr | awk '/ connected/ && !/primary/'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.