Stuck with a single sed script
I have to write a single sed script that will remove items in a text file that was assigned to work with. The issue that I have is I have to delete just the part of the line that ends with 500 Please help!
Here is what the text looks like: Hollywood, CA 91464:6/23/23:14500 Decatur, IL 75732:2/28/53:123500 Gary, IN 83756:12/1/46:268500 Milton, PA 93756:9/21/46:43500 Bath, WY 28356:5/13/69:24500 Farmount, IL 84357:1/1/67:89500 And again I have to write a single sed script and cat the script in the text to make the changes and I have an even bigger challenge after this. I have to change the names to be last, first name and the currently are listed as first, last name. I have attempted several scripts already and I have yet to get it to work, such as /...500$// /...500$d/ |
show us what you have already and we can assist further...this seems like home work, as per forum rules , we cant do home work for you.
|
Quote:
With sed you can search for a certain pattern and perform an action if that pattern is found. The solution you played with (/...500$d/) is close but syntactically incorrect. You first tell sed what you are looking for, 500 at the end of a line: /500$/. Then you tell sed what you want to do, in this case you want to delete the line, which is done by the d option. Putting both together will give you this: /500$/d Here's a link to a good sed tutorial: Sed - An Introduction and Tutorial This explains the delete option: Sed - Delete with d |
|
Thank you everyone for your assistance, it is actually a project that I am working on I work in academia and I am new to Unix scripting/programming.
|
All times are GMT -5. The time now is 10:27 AM. |