Skip to content
Advertisement

Tag: sed

The sed command is not working with regex

I’m parsing the output of a HTTP GET request with sed to retrieve the contents of a given html tag. The result of that request is like this: “<!DOCTYPE html><html><body><h1>Hello!</h1><p>v1.0.4-b</p></body></html>” And I want to retrieve the version number inside the p element. However, sed seems to have a bug in regex parsing. When I use: sed ‘s/.*<p>//’ It correctly replaces

Find and replace words using sed command not working

I have a a text file which is tab separated, the first column holds the word to be found and the second column holds the word to replace the found word. This text file contains English and Arabic pairs. Once the word is found and replaced it should not be changed again. For example: So for a given text file:

Remove eveything before including colon and replace comma to newline

I am looking just to accommodate my query into one-liner. I have a below file content where i want to remove all before last colon(:) including itself and then replace comma(,) into newline to get the desired results. these all comma separated values are linux user ID’s File content: Already tried: working solution: result: Is there a better trick, please

How to replace newlines between brackets

I have log file similar to this format Here is the echo command to produce that output $ echo -e “test {nseq-cont {nttt0,nttt67,nttt266nttt},nttgrp-id 505nt}n}ntest{nttest1{nttvalnt}n}n” Question is how to remove all whitespace between seq-cont { and the next } that may be multiple in the file. I want the output to be like this. Preferably use sed to produce the output.

linux replace string in files recursively

I have a folder which is full of *.java files. it has the following method in it: i wanted to change this as following: I have searched in the forum and found some solutions, replce string is what i wanted so tried the following: But it throwing me the following error: I guess the old_string and new_string formates are the

Replacing line of text cointing using sed

I’m trying to replace document.querySelector(‘.popup’).classList.add(‘active’) by document.querySelector(‘.popup’).classList.add(‘noactive’) Answer You can use See the online demo. The regex is POSIX BRE compliant and matches (document.querySelector(‘.popup’).classList.add(‘) – Group 1 (1): a literal document.querySelector(‘.popup’).classList.add(‘ text (active’)) – Group 2 (2): a literal active’) text. Note the capturing groups in a POSIX BRE regex are set with (…). The literal dots need escaping and

Advertisement