Drop all lines until

 · 1 min · torgeir

Terminal Linux Sed Grep Sensors

When you need to grep out some part of an output that appear several times, but you only want the one after x.

Go for sed , like this

sensors | sed '0,/amdgpu/d' | grep -m 1 fan1

It drops everything from line 0, after running the sensors command, including the first line that contains amdgpu. Then grabs a single line containing fan1, with grep -m 1.

Super useful if fan1 appears multiple times in the output.

What does the command do? This command in particular grabs the fanspeed of my gpu’s fans, which I also use as a case fan for intake.