使用該命令(upower -i /org/freedesktop/UPower/devices/battery_BAT1
)我的終端顯示下面的輸出:需要的「grep」多輸出
native-path: BAT1
vendor: LG
power supply: yes
updated: mar 31 may 2016 12:45:15 CEST (101 seconds ago)
has history: yes
has statistics: yes
battery
present: yes
rechargeable: yes
state: fully-charged
warning-level: none
energy: 50,4088 Wh
energy-empty: 0 Wh
energy-full: 51,4522 Wh
energy-full-design: 48,1 Wh
energy-rate: 6,29 W
voltage: 8,313 V
percentage: 97%
capacity: 100%
icon-name: 'battery-full-charged-symbolic'
我需要獲得與輸出的數據的數組。像這樣的東西:[BAT1, LG, yes, [...], 100%, 'battery-full-charged-symbolic']
任何方式來做到這一點?
你的意思是一個Bash數組嗎? –