How could I grep a line of text, and delete certian fields?
Expand Post »
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?
here it will delete the 4 and 5 file and transfer the remaing file in newfile
regards
whizkidash
Last edited by peter_budo; Nov 7th, 2009 at 5:33 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Re: How could I grep a line of text, and delete certian fields?
Hi ,
Example as below
Suppose u have file called file1 and it contains:
vi file1
Hi this line one
this is line two
this is line three
this is line four
this is line five
Now you want to delete the 1st and 5th line and transfer the remaining lines to newbee file
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.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Previous Thread in Shell Scripting Forum Timeline:Hey guys!!!
Next Thread in Shell Scripting Forum Timeline:CRONTAB help