I don't think it's a linux emulation thing. Also, I'm by no means
a regex person, but what about plain grep and/+ awk?
$ grep "cpu MHz" /proc/cpuinfo
cpu MHz : 2992.845
$ grep "cpu MHz" /proc/cpuinfo | awk '{print $4}'
2992.845
Sean
--
Fri, 04 Apr 2008 23:01:38 -0500
> $ grep "cpu MHz" /proc/cpuinfo | awk '{print $4}'
> 2992.845
i.e. $ awk -F':' '$1 ~ /MHz/ {print $2}' /proc/cpuinfo
Cheers;
E!
> This email was Anti Virus checked by Astaro Security Gateway.
> http://www.astaro.com
>
>
>
This email was Anti Virus checked by Astaro Security Gateway. http://www.astaro.com
If so, what about:
$ awk -F':' '$1 ~ /MHz/ {print $2}' /proc/cpuinfo
Cheers;
E!
>
> I'm trying to have a sed script get the cpu frequency from /proc/ cpuinfo.
> I know there are other applications that could possibly do the job, but
I need to get it from cpuinfo.
>
> This is how I think it should be done:
> sed 's/^cpu Mhz\\s\\+: \\(.\\+\\)\\..*$/\\1/p' /proc/cpuinfo
>
> And this returns: processor: 0
> I don't see how the ^cpu Mhz regex matches processor.
> I thought my regex-fu was stronger that this maybe I was wrong.
>
> Maybe it's a linux emulation issue that I'm not aware of.
>
> >
>
> $ awk -F':' '$1 ~ /MHz/ {print $2}' /proc/cpuinfo
> grep "cpu MHz" /proc/cpuinfo | awk '{print $4}'
--
you must know the ledge of wise and dome to understand your culture of freedom!
http://pxpippen.blogspot.com/
http://groups.google.com/group/lispstl
Powerfull Allah
One way to do this with sed:
$ sed -rne '/^cpu MHz/s/^.*: (.*)\..*$/\1/p' /proc/cpuinfo
Another:
$ sed -ne '/^cpu MHz/{s/^.*: //;s/\..*$//;p}' /proc/cpuinfo
And then there's the xml way (sort of):
$ sudo lshw -xml |
xmlstarlet sel -t \
-m "/node/node[@id='core']/node[@id='cpu']/capacity" \
-v "concat(.,' ',@units)" -n
Regards,
- Robert
> $ sed -rne '/^cpu MHz/s/^.*: (.*)\..*$/\1/p' /proc/cpuinfo
>
> Another:
>
> $ sed -ne '/^cpu MHz/{s/^.*: //;s/\..*$//;p}' /proc/cpuinfo
Works like a charm with sed -nE '-)
Nice - I would not have thought to use sed to both parse and edit out the
remainder.
Very efficient.
Cheers;
E!
Cool. Learn something new everyday!
Sean
--
Sat, 05 Apr 2008 02:00:22 -0500