I'm wirting the simple script for cleanup some unused strings.
and i used awk '/^EEEEEEEEE$/,/^$/' file to grep the scope which is need to delete.
As i know i can use sed -i '/<parrten>/d' file to delete a line from the file.
The intrest thing is when i combined them in the for loop then the sed command cannot delete lines, and i also checked the varibales in the for loop block the string is correct.
For Loop
#!/bin/bash
for i in $(awk '/^EEEEEEEEE$/,/^$/' file); do
echo $i
sed -i '/$i/d' file
done
File content:
AAAAAAA
BBBBBBBB
CCCCCCCC
DDDDDDD
EEEEEEEEE
FFFFFFFFF
GGGGGG
HHHHHHH
LLLLLLLLL
PPPPPPPP
I'm not sure there is any missing or incorrect. I just want to make sure can delet them