Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
relatively new to this. Hope someone can help me.
I need to read from a file.
11 columns, each column is separated by a space. contains numercial values only. each rows can have integer of value 1-5 & a "-" .So what I did was to use
a while loopbasically something like this
while read a b c d e f g h i j k
do
x=`expr $b $c... $k`
dont <input file
#a can be ignore at the moment. for it is something like identificationbut however becoz of the "-" in the rows, i need to replace each "-" with a 0. but not sure how to do so.
i know it is something like ${var:0}
but i am not sure how to implement into the script... plus after so I need to count the number of rows which doesnt contain "-"..Really hope someone can help me out here.

How about
#!/bin/ksh
integer a b c d e f g h i j k
sed 's/-/0/g' xx.dat | while read a b c d e f g h i j k
do
print $a $b $c $d $e $f $g $h $i $j $k
done

if let's say i have this
1234567 1 2 3 4 5 5 6 7 8 -
and many other simlar lines..i need to count the number of int from the second columns onwards. How do i tell the system to like check for every "-", and do a subtraction from 10. coz 10 is the total number of columns beside the one column.
anyone has a gd idea????

![]() |
![]() |
![]() |

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