If you are expecting to delete a line that starts with a pattern, then you should use the anchor symbol (^
) in the beginning of the pattern :
sed -E '/^\[/d' filename > newFile
To accommodate blank spaces in the beginning of the pattern which is common as a result of indentation, you should do
sed -E '/^[[:blank:]]+\[/d' filename > newFile
GNU sed
has an inplace-edit option realized thru -i
option, so above could be replaced by
sed -Ei '/^[[:blank:]]+\[/d' filename
It seems that sed
has no limits concerning file size but it is typically slow for a large file.