我想删除不需要的数据。所以我的问题是,如果 test1 上面不包含 test1或不以引号结尾,我该如何删除它?
20 /test1/catergory="Food"
20 /test1/target="Adults, \"Goblins\", Elderly,
Babies, \"Witch\",
Faries"
**This is some unwanted data to remove**
20 /test1/type="Western"
20 /test1/end=category
**This is some unwanted data to remove**
20 /test1/Purpose=
20 /test1/my_purpose="To create
a fun-filled moment"
20 /test1/end=Purpose
Run Code Online (Sandbox Code Playgroud)
预期输出:
20 /test1/catergory="Food"
20 /test1/target="Adults, \"Goblins\", Elderly,
Babies, \"Witch\",
Faries"
20 /test1/type="Western"
20 /test1/end=category
20 /test1/Purpose=
20 /test1/my_purpose="To create
a fun-filled moment"
20 /test1/end=Purpose
Run Code Online (Sandbox Code Playgroud)
我被这几个命令困住了:
1. grep -B1 'test1' test_long_sentence.txt
2. sed '/test1/!d' test_long_sentence.txt
3. sed '/\"$/!d' …
Run Code Online (Sandbox Code Playgroud)