0
votes
1answer
234 views

How to replace text strings by reading in list using sed

I'm trying to come up with a sed script to run from the shell. I need to be able to read in a list of UUIDs from an external file, which contains two columns origtexta replacementa origtextb ...
1
vote
2answers
59 views

Is there a way to print 2 lines (if any) before and after a target or print a placeholder if not?

I'm not native english speaker so I hope to be clear. I know about grep -C 2 "TARGET" inputfile to select 2 rows before and after the row of the TARGET, but I'm not able to use it to manage my ...
3
votes
4answers
890 views

How to replace a list of strings by another list

I have a file which has (many) strings I'd like to replace, so I thought about using a simple command like: sed 's/string1/string2/g' file1 > out However, there are too many strings for that ...
1
vote
2answers
156 views

Parsing two input files and comparing line existence

I need to take two text files and check to see if a line that exists in File A doesn't exist anywhere in File B. Each line in File A that does not exist in File B should be copied to an output log. ...
2
votes
1answer
170 views

Delete first lines from a Unicode html file

I have an HTML file that is in UTF-8 format and I want to remove the first five lines from it. I've tried using sed but it doesn't work in this case: sed "1,5d" Result.html>small2 It actually ...
0
votes
2answers
500 views

Using sed, how to print all lines that match a certain date?

Using sed, how to print all lines where the birthdays are in November or December? Assuming input file name "datebook" as follows: Steve Blenheim:238-923-7366:95 Latham Lane, Easton, PA ...
2
votes
3answers
314 views

Adding text to the beginning and end of a number of files?

I have a number of files in a directory hierarchy. For each file, I'd like to add "abcdef" to the beginning, on its own line, and "ghijkl" to the end, on its own line. For example, if the files ...
2
votes
3answers
354 views

How to substitute multiple lines between delimiters

Given the text example: .... text ,.. {{{python string1 = 'abcde' string2 = '12345' print(string1[[1:3]]) print(string2[[:-1]]) }}} .... text ,.. The [[ and ]] also appear outside of {{{ too. ...
0
votes
2answers
3k views

What is the ^I character and how do I find it with sed?

I usually import data from csv files to MySQL, but my data provider leaves NULL entries as "", so I need to replace "" with "\N". This is easy enough with a script like for csvfile in *.csv do ...
0
votes
2answers
2k views

Exclude some matches with sed

I have a series of files with entries(namespaces in source code) like FW.WGS.Web.HHH.Controls, FW.WGS.Web.HHH.Email, FW.WGS.Web.HHH.Account, etc and some with entries FW.WGS.Web.Controls, ...