On Thu, 2003-04-03 at 07:50, santosh kumar wrote: > Hi guys, > > Have small doubt in bash scripting..(#!/bin/bash) > Need to write script to get all m/c info, If I do cat /proc/cpuinfo will > display CPU info. > My requirement is grep CPU model, speed and display the outputs like > For example m/c has single CPU > > CPU model : pentium III > CPU speed : 1.73 GHz > I am getting correct output for single CPU but getting confusion for > more than one CPU. > > If more than 1 CPU then my output has to be like this > > 1st CPU model : pentium III > 1st CPU speed : 1.73 GHz > 2nd CPU model : pentium IV > 2nd CPU speed : 2.4 GHz > > Please give some tips.. > I would use awk. Depending on how stringient your requirements are this should be close
awk -F : '/processor/{cpunum= $2+1};/model name/{print "CPU " cpunum " model : " $2};/MHz/ {print "CPU " cpunum " speed : " $2}' /proc/cpuinfo HTH Bret -- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED] https://listman.redhat.com/mailman/listinfo/redhat-list