I would need to edit the values in a file delimited by colons (:)
I would like to replace the contents of the file by using regular expression. After a grep to confirm that the item exist in the file system. I would like to edit the contents inside it by using sed.
I am open to the use of others tools. That would help me.
EDIT:
So far i have been trying to use sed to modify the contents in the text file in test.txt. The current solution i could think of is sed.
sed -i "s/^\($newEvent:$newPerson:[^:]*\):[^:]*:/\1:$newQty:/" test.txt
echo "item Qty has been updated successfully!"
Is there a way i am able to edit the content after a string matching of event && person and modify the contents of that line which matches.
Before any input content in text file
Birthday Party:John Harris:1:10:1
Enter Event: Birthday Party
Enter Person: John Harris
a) Update Event
b) Update Person
c) Price
d) Update Item brought
e) Update Quantity Sold
f) Back to main menu
Please enter your choice: d
New Qty Sold : 38
Qty Sold has been updated successfully!
a) Update Event
b) Update Person
c) Update Item brought
d) Update Quantity Sold
e) Back to main menu
Please enter your choice: f
After input content in text file
Birthday Party:John Harris:1:10:1
test.txt? What is this "last item" which you "cant seem to successfully change"? Also,please explain what you're actually trying to do, what's the big picture?