Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi...need your expertise...I'm a newbie to scripting. I have a file whose numerical content, I need to multiply by 1000. The file is called crc.sdf
The format of its content is as follow.
(INTERCONNECT U663/Y ERRFLG (0.000082:0.000082:0.000082) (0.000082:0.000082:0.000082))
(INTERCONNECT U667/Y DOUTVALID (0.000054:0.000054:0.000054) (0.000054:0.000054:0.000054))
(INTERCONNECT DOUTREADY U524/A (0.000550:0.000550:0.000550) (0.000550:0.000550:0.000550))Basically I need to change those numbers, 3 numbers in each parenthesis (they represent time in ns to ps). It's probably easiest to search for . then take the number and multiply it but I'm not sure exactly how to do that. Any help is greatly appreciated.
Sup

Try this:
#!/bin/ksh
function count {
output1=$(print "$2 * 1000;scale=2" | bc)
output2=$(print "$3 * 1000;scale=2" | bc)
output3=$(print "$4 * 1000;scale=2" | bc)print "The results are $output1 $output2 $output3"
}
IFS="():
"exec 3 ./data.comp
while read -u3 line
do
case $line in
*I* ) : #print $line
;;
* ) count $line
;;
esac
donePlease note: There should be a left angle bracket between the exec 3 and the ./data.comp. That is what I named your data file as. Change it as appropriate.
Jerry

![]() |
how to read binary files ...
|
INformation about NIS
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |