From: Eric Christopherson Date: 2012-08-14T04:59:47+09:00 Subject: Re: delete a string from config On Mon, Aug 13, 2012 at 1:18 PM, Fosiul Alam wrote: > hi i am trying to automate a Firewall config and i have a bellow line in > a congig .. Someone just asked here about deleting lines from a file; this would be pretty much the same (i.e. you'd read in the file, make your deletions in the in-memory copy, and then write it out to disk). > "user1" "user2" "user3" "User4" .... > "user100" > > now i need to delete string "user2" > > but dont understand what would be the best way > > i was thinking to spilit this into array then delete the value then > create again with same syntax from array > > can any one please help me . I guess that depends on how the data's laid out. If it's really "user2" in quotation marks, I would do a gsub on /"user2"/ and replace it with nothing (unless you want to delete whitespace on one side or another, in which case you'd add that to your regular expression). But it might make sense to split it, delete instances of the string, and then rejoin it, before writing back to disk.