You are not logged in.

#1 2008-02-19 10:38:55

Korey Kaczynski
Member
Registered: 2007-11-30
Posts: 36

Getting information cleanly from /proc with bash/zsh [SOLVED]

I'm tired, so bear with me here sad

I want to be able to get the 0/1 value from /proc/pmu/info for my laptop in order to detect whether or not I'm connected with AC power.

Normally, the file looks something like this:

PMU driver version     : 2
PMU firmware version   : 0c
AC Power               : 1
Battery count          : 1

I'm trying something like "cat /proc/pmu/info | grep "AC Power" | cut -d : -f 2" to obtain the boolean value, but there's whitespace in the result (as you can probably see why).  What would be the best way of getting the value?

Last edited by Korey Kaczynski (2008-02-19 12:28:52)

Offline

#2 2008-02-19 11:56:53

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: Getting information cleanly from /proc with bash/zsh [SOLVED]

awk '/Power/ {print $4}' /proc/pmu/info

Last edited by lucke (2008-02-19 11:59:41)

Offline

#3 2008-02-19 12:28:23

Korey Kaczynski
Member
Registered: 2007-11-30
Posts: 36

Re: Getting information cleanly from /proc with bash/zsh [SOLVED]

Thanks!  Looks like I ought to start familiarizing myself with awk.

Offline

Board footer

Powered by FluxBB