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.
Tag: sed
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
Use values in a column to separate strings in another column in bash
I am trying to separate a column of strings using the values from another column, maybe an example will be easier for you to understand. The input is a table, with strings in column 2 separated with a comma ,. The third column is the field number that should be outputted, with , as the delimited in the second column.
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
How to split a text file into blocks with 10+ characters without dividing words using sed in Linux?
I want to come up with a sed command where once every 10 character will look for the nearest space and substitute it with “|” I tried sed -E -e ‘s/ /|/( *?[0-9a-zA-Z]*){10,}’ new.file, but it shows errors. Example input: Expected Output: Answer This works for given sample: (.{10}[^ ]*) this matches 10 characters, followed by any non-space characters then
Replacing a string in the beginning of some rows in two columns with another string in linux
I have a tab separated text file. In column 1 and 2 there are family and individual ids that start with a character followed by number as follow: I would like to replace NA with HG in both the columns. I am very new to linux and tried the following code and some others: Any help is highly appreciated. Answer
To read desired values from file using linux system commands (grep,awk,sed) [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year. Improve this question I have file test.txt contains some variables assigned to some value, i need to read all defined variables for example color
grep to read exact data from text file
I have file test1.txt file, i am trying to read variable which is enclosed in double quotes and starting with hyphen for eg: “-color”. i trying to use this grep command cat test1.txt | grep getParm | sed ‘s/getParm(/ /;s/&/ /;s/,/ /;s/”/ /g’ | awk ‘{print $3}’ , where i am not able to read exact data for all variables
get multiple words after a specific word of HTML using linux/unix scripting
i have a file ‘movie.html’ : I want to get multiple word with pipe delimited like this: I tried this code: but the output isn’t as my expectation please help me, i am still a beginner Answer Parsing html with regex is not advised for several reasons (see https://stackoverflow.com/a/1732454/12957340), but here is one potential solution:
Parse From Text File into String output
So I have a text file called employees.txt that looks like this… I’m trying to write a sed script that will read in the text file then output it in the format “< name > is a < gender >, and is < age > years old now.” I know I need to set the IFS=, but I’m stuck on