cut

Discuss Programming
Post Reply
X11
guru
guru
Posts: 676
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia
Contact:

cut

Post by X11 »

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.

Tux
guru
guru
Posts: 689
Joined: Wed Jan 08, 2003 10:40 am

Post by Tux »

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

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

And if you wanted to get rid of the space you could add a "| tr -d ' '" to the end of Tux's pipe.

X11
guru
guru
Posts: 676
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia
Contact:

Post by X11 »

Cool, I can fianlly use this to finish my old shell scripted uptimes project client.

Post Reply