Skip to content
Advertisement

Tag: sed

ignoring variable containing and multiple spaces usnig sed command

I have two variables, i want to replace ESX_10.2.3.4@10.52.33.21 with new pool ser/@10.25.89.322 and also want to remove space before new word. i have tried like, and I don’t want to delete space ,just want to replace as it is(except space before “new”). Answer Give a try to this: It is removing the space in the first occurrence of new

Comparing two files at end of line in Linux

I would like to compare two files and get the output of matching string in one of the files at the end of the line: Let’s say I have two files:- file1: file2: I could do something like this: This gives me the following output: This is because abcdef in file2 matches both of those lines in file1. However, what

Replacing strings with special characters in command line sed

I want to uncomment a line of a config file by replacing the line %% {some_string, []}, with {some_string, []} in the command line. I have tried a few different formats using sed: sed ‘s/%% {some_string, []},/{some_string, []}/’ filename sed “s/%% {some_string, []},/{some_string, []}/” filename sed “s/’%% {some_string, []},’/'{some_string, []}’/” filename sed ‘s/”%% {some_string, []},”/”{some_string, []}”/’ filename but every time

replace text between two tabs – sed

I have the following input files: and I am trying to find the second string between the two tabs (e.g. text2, abc2) and replace it with another word. I have tried with but it only deletes the tab and does not replace the word. I appreciate any help! Answer I would suggest using awk here: Set the input and output

Replace line with double quotes

I want to replace a line with double quotes on OpenBox startup, like: with I use this command, but it does not work: It gives me this error: Answer The ampersand in the replacement string recalls the pattern in the search string. So you can just do this: Also, you can use single quotes on the outside, and double quotes

formatting the output with sed command

I need your help… I got this kind of text: and the output I need is (first and second column and socialSecurityNumber OR tng-customer-id): So the question is … is it possible to solve this issue with sed command? I need the OR option here. If I try to do it separately, firstly, find the socialSecurityNumber, I get this: secondly,

Advertisement