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).
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.
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).
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.