-3

I have a line which looks like this: </File2>. I want to remove it using sed, but nothing I tried worked, I tried

sed '/^<\/File2>$/d'

so I thought maybe theres special characters at the end, but:

sed '/^<\/File2>/d'

didn't work either. I cannot remove the ^ in the beginning, because's there's lines I want to keep that includes </File2>.

closed as off-topic by Michael Homer, Jakuje, Jeff Schaller, roaima, muru Apr 24 '16 at 1:38

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Michael Homer, Jakuje, Jeff Schaller, roaima, muru
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    This is your second post today regarding parsing xml with regex. See the following: stackoverflow.com/a/1732454/1032785 – jordanm Apr 23 '16 at 2:54
  • 1
    @jordanm I have read that multiple times. It's a childish answer and says nothing. This is also not complicated at all and sed should be able to handle it, the reason sed is failing is not because of the tags. – DisplayName Apr 23 '16 at 2:57
  • 2
    In fact, could you just provide your actual data? "I have some data that behaves this way" isn't terribly helpful, especially when you suspect hidden characters. hexdump it if necessary. – Michael Homer Apr 23 '16 at 3:07
  • 2
    No, it isn't, it's a statement that says "I have a line which looks like this: </File2>.". You've described what it looks like. Provide an example input that reproduces your problem. Use hexdump (or hd) to represent it if necessary. – Michael Homer Apr 23 '16 at 3:16
  • 1
    Alternatively, you could post a minimal reproducing file off-site. Just some way that people can see exactly what's in there, because that's going to be what diagnoses the problem. – Michael Homer Apr 23 '16 at 3:18
-1

Running tr -d '\r' on the file before removing the lines work.

No idea why, but when I ran this command it revealed another tag as well as a space before <\/File2>.

  • Not sure why I was down voted. It worked. – DisplayName Apr 24 '16 at 0:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.