I have read many threads, but I still didn't find the right answer. May be i didn't find the right thread, though are so many threads for the same question.
Basically the situation is - find date in a file and replace it with another date. (its not homework, its part of lot of a big processing, so just extracting this piece of problem)
A file would contain records like this
john 2011/06/28 11:16:14
smith 2011/06/28 12:46:10
jessica 2011/06/28 06:16:40
I need to find john, replace the date on the same line with another date. I can find the required line, i am facing problem replacing the date. Here is the extracted code.
Hence i get
sed: -e expression #1, char 21: unterminated `s' command
I got to know it has to do with the characters "\" & ":", but what exactly is the problem and what is the solution?
Can anybody explain me please?
---------- Post updated at 12:54 PM ---------- Previous update was at 12:48 PM ----------
Just figured out that I could replace the date and time separately, but not together. I think the space between the date and time is the problem.
Am I right?
I have tried almost all sorts of combinations, none of them have worked. Even this one didn't work.
I want to understand what's happening behind the scene.
The below would not throw sed error posted by you.. but it neither matches the oldDate. Storing the pattern in a variable and trying to match it in Sed is IMO a bad idea. However you can try as
echo 'john 2011/06/28 11:16:14' | sed "s|$oldDate|$newDate|"