SED Regular Expression Problems
Posted on 2004-07-30
I am trying to use SED to change the headers of an e-mail.
A typical e-mail might be:
Date: Tue, 22 Apr 2004 15:33:15 BST
From: "Someone" <firstname.lastname@example.org>
To: "You" <email@example.com>
I am trying to change the "Received: " part of the header to "Received: from " (which is not difficult at all. The problem comes when some of the e-mails will already containg "Received: from " and so, they should not put another "from" in there.. i.e.
Received: from from subnet.server.com
The regular expression I am using at the moment (which does not work) is :
sed 's/Received:\s+(from\s+)/Received: from/' filename
Could you possibly tell me how to do this please?