You are not logged in.
I have following output when I run a command below:
$ likwid-powermeter sleep 5 | grep 'Joules\| s'
Runtime: 5.00299 s
Energy consumed: 17.9783 Joules I would like to extract only 5.00299 and 17.9783. How can I do this?
I tried to use awk and cut.. but I could not get it the way I wanted, I could only cut one column.. but those values are two different columns. 5.00299 is in 2nd column on first line and 17.9783 is in 3rd column in the 2nd line.
When I tried to pipe everything to cut I was getting following:
$ likwid-powermeter sleep 5 | grep 'Joules\| s' | cut -d' ' -f3
s
18.7806 What can I do?
Last edited by kdar (2012-11-14 06:34:14)
Offline
awk 'NR==1{print $2} NR==2{print $3}' < commandYou could probably do without the grep as well; awk can handle that...
Offline
awk '{ print $(NF -1) }'
Brutal.
Offline
wow.. thank all. I didn't know how to specify lines in awk.
How does NF -1 work?
Offline
Offline
Please mark [solved], as I'm pretty sure it is ![]()
Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.
Offline