How could I grep a line of text, and delete certian fields?

I need to grep a line from a text file, and delete the fourth and fifth field. then save it back to the text file. If that wont work I could also grep the line, and delete the first number and everything after it on that line. Both would accomplish my goal. Forgive me, I am a little newbish, but can anyone help?

I need to grep a line from a text file, and delete the fourth and fifth field. then save it back to the text file. If that wont work I could also grep the line, and delete the first number and everything after it on that line. Both would accomplish my goal. Forgive me, I am a little newbish, but can anyone help?

I want to grep the line containing TOOL, and delete the the 3rd and 4th field (field separator is : ), and change "IN" to "OUT" so the result is

cat file.txt
HOOK:MARK:IN
TOOL:TIM:IN
BULB:MIKE:IN

This script below gives me the proper result, but I had to cheat to do it. I just substituted "OUT:06/12/2007:MATT" for "IN" and appended it to the file.txt and then deleted the entire old line. Only problem is that the line is now at the end of the file and not in its original spot, which is not a problem at all in my case, but I am still interested if it can be done the way I originally asked.

This script below gives me the proper result, but I had to cheat to do it. I just substituted "OUT:06/12/2007:MATT" for "IN" and appended it to the file.txt and then deleted the entire old line. Only problem is that the line is now at the end of the file and not in its original spot, which is not a problem at all in my case, but I am still interested if it can be done the way I originally asked.

Hi. so this is actually a continuation from another question of mine[Here](https://www.daniweb.com/programming/software-development/threads/506795/dynamically-add-values-into-datagridview-cell-from-listbox-vb2010) but i was advised to start a new thread as the original question …

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...