You can use the following:
sed '/{START-TAG/{:a;N;/END-TAG}/!ba};/ID: 222/d' data.txt
Breakdown:
/{START-TAG/ { # Match '{START-TAG'
:a # Create label a
N # Read next line into pattern space
/END-TAG}/! # If not matching 'END-TAG}'...
ba # Then goto a
} # End /{START-TAG/ block
/ID: 222/d # If pattern space matched 'ID: 222' then delete it.
Related Contents:
- awk or sed extract each number of column alone
- sed substitution with Bash variables
- How can I do a recursive find/replace of a string with awk or sed?
- Bash tool to get nth line from a file
- How to merge every two lines into one from the command line?
- How to pass a variable containing slashes to sed
- sed search and replace strings containing / [duplicate]
- Recursively rename files using find and sed
- Error when using ‘sed’ with ‘find’ command on OS X: “invalid command code .”
- How can I remove the first line of a text file using bash/sed script?
- Remove first N lines of a file in place in unix command line
- How to address error “bash: !d’: event not found” in Bash command substitution [duplicate]
- How to add to the end of lines containing a pattern with sed or awk?
- Remove Unicode characters from textfiles – sed , other Bash/shell methods
- How to replace an entire line in a text file by line number
- Using sed to mass rename files
- Use sed to replace all backslashes with forward slashes
- Delete all lines beginning with a # from a file
- Insert newline (\n) using sed
- Why does sed not replace all occurrences?
- How to remove double-quotes in jq output for parsing json files in bash?
- How do I escape slashes and double and single quotes in sed?
- Expand variables in sed
- How to use a bash script variable with sed [duplicate]
- Error with sed unterminated s command in bash
- How to grep for case insensitive string in a file?
- Scripts for computing the average of a list of numbers in a data file
- How to match a single quote in sed
- Escaping forward slashes in sed command [duplicate]
- How do you run multiple programs in parallel from a bash script?
- How to use a variable’s value as another variable’s name in bash [duplicate]
- Return value in a Bash function
- How to pipe input to a Bash while loop and preserve variables after loop ends
- Checking the success of a command in a bash `if [ .. ]` statement
- How can I exclude all “permission denied” messages from “find”?
- Bash script and /bin/bash^M: bad interpreter: No such file or directory [duplicate]
- How to recursively find the latest modified file in a directory?
- Bash script compare two date variables [duplicate]
- Why can’t I use job control in a bash script?
- Send string to stdin
- In what order should I send signals to gracefully shutdown processes?
- Specify other flags in awk script header
- How do I prompt a user for confirmation in bash script? [duplicate]
- Select random lines from a file
- How to include an ‘&’ character in a bash curl statement
- bash set -e and i=0;let i++ do not agree
- Assign string containing null-character (\0) to a variable in Bash
- Script to get the HTTP status code of a list of urls?
- Get exit code from subshell through the pipes
- How do I kill a backgrounded/detached ssh session?