@Beginners, might want to ask the purpose of attempting to edit the /etc/shadow by hand in this manner, in other words, what is the desired outcome that you wish to achieve?
As for understanding the whole history of the errors you are receiving, depending on your knowledge and understanding of C, there is a wealth of informative documentation at the source archive. If you search specifically for the errors you are receiving, you will find them, and see that they relate to errors you are seeing:
static char *
hist_error(s, start, current, errtype)
char *s;
int start, current, errtype;
{
char *temp;
const char *emsg;
int ll, elen;
ll = current - start;
switch (errtype)
{
case EVENT_NOT_FOUND:
emsg = "event not found";
elen = 15;
break;
case BAD_WORD_SPEC:
emsg = "bad word specifier";
elen = 18;
break;
case SUBST_FAILED:
emsg = "substitution failed";
elen = 19;
break;
case BAD_MODIFIER:
emsg = "unrecognized history modifier";
elen = 29;
break;
case NO_PREV_SUBST:
emsg = "no previous substitution";
elen = 24;
break;
default:
emsg = "unknown expansion error";
elen = 23;
break;
}
There may be an easier way to achieve the ends you desire, which is why I ask what that may be. If the ends are known, then the path is likely much traveled by many before, and an answer easier to deliver to assist you. ;)
Also, in reviewing the command, did not notice usage of the sudo convention, which would be necessary to complete any administrative function successfully. Remember that certain functions will not work without the correct privileges consumed at the time of execution.
HTH. Have a nice day. :)