Skip to content

Tag: sed

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…

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 out…

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 dou…

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 socialSecu…