Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting rows 2

Status
Not open for further replies.

hill007

Technical User
Mar 9, 2004
60
US

I have a file with 10 fields and every 4th row has 4 fields. I want to multiply this matrix file with a value of 0.08333.
When I multiply the full matrix using the command:
{print ($1*0.08333,$2*0.08333,$3*0.08333,$4*0.08333,$5*0.08333,$6*0.08333,$7*0.08333,$8*0.08333,$9*0.08333,$10*0.08333 ) } it multiples, however it adds 6 more fields in the 4th row with zeros.
I then tried to remove the 6 fields from the 4th, 8th, 12th, etc rows by using the command:
NR==4{print ($1,$2,$3,$4,$5=$6=$7=$8=$9=$10=””)}
NR==8{print ($1,$2,$3,$4,$5=$6=$7=$8=$9=$10=””)}
NR= {print ($1,$2,$3,$4,$5=$6=$7=$8=$9=$10=””)}
(NR==1),/stop/{print}

what this does, is removes the fields from the 4th, 8th, and 12th rows and keeps the first four fields in these rows. However, it adds extra one row with the same four fields below. My matrix is 447 MB and it is tedious to go and delete those rows manually.
Could you please help me as how to write the script or modify the above scripts.
Attached is an example data set.
Thank you so much.

Example data set:
0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768
0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768
0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768
0.0768 0.0768 0.0768 0.0768
0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768
0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768
0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768
0.0768 0.0768 0.0768 0.0768
0.0468 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768
0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768
0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768 0.0768
0.0668 0.0768 0.0768 0.0768
 
{
for(i=1; i <= NF; i++)
$i *= 0.08333;
print;
}

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Since this is Awk, not Perl or C, the semicolons are superfluous (but harmless).
[tt]
{ for(i=1; i <= NF; i++)
$i *= 0.08333
print
}
[/tt]
 
another purist, eh? [wink]

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top