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.
···
On Mon, Aug 13, 2012 at 1:18 PM, Fosiul Alam <lists@ruby-forum.com> wrote:
Look at the tokenizer. use the string to be removed as the divider like the comma in a csv.
Then output the tokens as a single string. (all remove all instances of it).
···
On 14 Aug 2012, at 12:58, Fosiul Alam <lists@ruby-forum.com> wrote: