Re: [go-nuts] Find a string in a file and delete all occurences in the file

2017-04-23 Thread Konstantin Khomoutov
On Sat, 22 Apr 2017 08:08:57 -0700 (PDT) Vikas Kumar wrote: > I am trying to iterate over an array, match the lines in a file and > then delete all occurrences of the lines in the file. > > See this example. > *Array* > var abcd = [5]string{ > "one two", > "three

[go-nuts] Find a string in a file and delete all occurences in the file

2017-04-23 Thread Tamás Gulácsi
The easiest would be that sed. Otherwise, do as sed: iterate through the lines with a bufio.Scanner, and write out libes into a bytes.Buffer iff it doesn't match. At the end, overwrite the file with buf.Bytes using ioutil.WriteFile. -- You received this message because you are subscribed to the

[go-nuts] Find a string in a file and delete all occurences in the file

2017-04-22 Thread Vikas Kumar
Hey All, I am trying to iterate over an array, match the lines in a file and then delete all occurrences of the lines in the file. See this example. *Array* var abcd = [5]string{ "one two", "three four fix", "six", "seven eight nine ten", "eleven twelve thirteen fourteen