How can you remove one line which contains the word SID in many files?
I wondering between sed and tr. However, neither of them seem to work for the purpose. I also would like to have some flexibility because of the following reason.
The problem is actually slightly more challenging. I need to remove also one line after the match in some files, while one line before in the other files. The one line has the character &
which determines whether to remove one line below or above or only the match.
It is likely that the easiest way is to make a list of different types of files and then remove the files in each list with different codes.
Examples of the data
Here &
. "question_sent"
. "&" // I do not want this line
. htmlspecialchars(SID) // NOT wanted
. "&"
. "email="
No & here
. "successful_registration&"
. "SID=" // Not wanted
. htmlspecialchars($SID) // Not wanted
. "&" // not wanted
. "email="
The character &
is now in HTML encoding that is &
if(isset($_GET['ask_question'])) {
echo ("<li id='ask_question_active'><a href='?ask_question&"
. htmlspecialchars(SID) // not wanted
. "&" // not wanted
. "email=