How do I delete a line from the form ARRAY = & hellip ;; with sed?


I'm trying to learn sed, but I encountered a problem. Let me explain, I have a file called in:


where anystring means that there can be the code I want to, since it's only an example. Now with sed i want to remove the line "ARRAY=...;"

I tried with:

sed "/#ARRAY=.*;/d" in > out

But with no success, while:

sed "/ARRAY=[a-z]*;/d" in > out

Is working fine for me. The problem is that after "ARRAY=" there can be all the characters (except of ; obviously).

How can I do this?

Try this:

sed '/^ARRAY=.*;/d' in >out

The beginning of the line is expressed as ^, not #. If you accept leading whitespace, as suggested by Swiss in the comment, use

sed '/^[ \t]*ARRAY=.*;/d' in >out