cut

Discuss Programming

cut

Postby X11 » Mon Jul 21, 2003 12:53 am

I have been trying to work out 'cut'..

But there are no examples in the manpage, I want to get the last bit from this...

cat /proc/cpuinfo | grep "cpu MHz"
(Just the speed in mhz)

I cant work out the manpage, it doesnt really explain anything.
X11
guru
guru
 
Posts: 674
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia

Postby Tux » Mon Jul 21, 2003 4:59 am

cat /proc/cpuinfo | grep 'cpu MHz' | cut -d":" -f2

That is what you want, although it would return a rating to 3 decimal places.

If you would like an integer, use this:

cat /proc/cpuinfo | grep 'cpu MHz' | cut -d":" -f2 | cut -d"." -f1
Tux
guru
guru
 
Posts: 689
Joined: Wed Jan 08, 2003 10:40 am

Postby Void Main » Mon Jul 21, 2003 6:08 pm

And if you wanted to get rid of the space you could add a "| tr -d ' '" to the end of Tux's pipe.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby X11 » Sun Dec 14, 2003 12:34 pm

Cool, I can fianlly use this to finish my old shell scripted uptimes project client.
X11
guru
guru
 
Posts: 674
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests