echo "eh]" | sed -r 's/[\]a]/lol/g' returns eh] instead of ehlol. no errors are raised so I assume \] is some kind of sed magic. Im tired of constant sed problems, but I have to use it. so how to escape ] in sed substition expression?
How to escape ] char in character class in sed
919 Views Asked by nah At
1
There are 1 best solutions below
Related Questions in SED
- Use sed or rename find series of alphabet then replace with with the same alphabet and a dash -
- Delete first three lines containing a certain word
- How to use a loop to chain piped commands together?
- Executing sed from php script
- Sed bash replace containing a path pattern
- Order of options in Unix sed for editing files in-place
- How to change urlencode spaces inside a sed capture group only?
- How to use a variable command in a sed expression
- sed search and replace with spaces
- Can you replace a substring from a regex match?
- Truncating "wrapping" long string outputs with prefix, appends new line at the bottom of each dump of the hold space
- AWK or sed to print data in table format
- print lines with blank spaces or white spaces
- How to use sed in shell script with value containing line break \n?
- Replace the values under some columns using awk or sed
Related Questions in ESCAPING
- How is passing a function as a parameter related to escaping autoclosure?
- How to appropriately handle newlines and the escaping of them?
- How to assign a value to a string variable, that includes embedded '=' in the value
- How to escape angle brackets in YAML?
- How to write .csv that includes column containing text (and special characters) with pandas
- Laravel 10 partially unescaping back JSON strings with \n \r escape sequences inside
- Python Backslash JSON Escaping issue - adding unwanted double backslash \\
- How to escape Freemarker output of captured assign?
- escaping symbolic characters in strings programmatically (zsh)
- How do Jersey endpoints call each other?
- sudo command behaviour difference with the -i flag
- Why ^^! and not ^! for literal escapes during delayed variable expansion?
- Single quotes being swapped for double quotes upon replace
- How can I see the escape sequence of a given key combo (specifically Alt+letter) when I use the meta8 option in URxvt?
- How to parse a double quote at start of field in csv using jackson-dataformat-csv CsvMapper
Related Questions in SUBSTITUTION
- Substituting values in a Python sympy unknown function
- A multi-line substitution in RST
- Getting error 'Some bytes have been replaced with the Unicode substitution character while loading file ... with Unicode (UTF-8)"
- Extracting text after nth of a character and put in next row , under first row in Excel VBA Code
- Parsing data with Pandas - how to output match as a new column
- Substitution AND capitalize on ${var}
- CS50 - C -problemset 2 - substitution - output not valid ASCII text
- Is there a way to use the substitution function in VBA to change multiple values in a single column into a different text output?
- What is causing the inefficiency of GNU sed using `.*` substitutions?
- Google Sheets - replace the exact text/number with a different one ignoring other matching parts
- Variable substitution inside if statement
- Problem with Powershell variable substitution in Strings
- Substitue values in jq from a txt file
- Modifying a global variable works, but not when a pipe is used
- Turn off infuriating Xcode editor completions
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You can simply use
echo "eh]" | sed -r 's/[]a]/lol/g':]as first character inside the brackets.]and\have some specialties when used inside brackets. Let me cite from the documentation: