Module edit

Text file line editing.

Info:

Functions

insert_line(line, inserts, pattern, plain, before, after)
Insert lines into an existing file.

Promiser:

    path of text file to modify

Parameters:

  • line to insert [REQUIRED] [ALIAS: content]
  • inserts a line (string) if found, skips the operation
  • pattern line is added before or after this pattern [ALIAS: match]
  • plain turn on or off pattern matching facilities [DEFAULT: "yes", true]
  • before [DEFAULT: "no", false]
  • after [DEFAULT: "yes", true]

Usage:

    edit.insert_line("/etc/sysctl.conf"){
        pattern = "# http://cr.yp.to/syncookies.html",
        content = "net.ipv4.tcp_syncookies = 1",
          after = true,
         plain  = true
    }
remove_line(pattern, plain)
Remove lines from an existing file.

Promiser:

    path of text file to modify

Parameters:

  • pattern text pattern to remove [REQUIRED] [ALIAS: match]
  • plain turn on or off pattern matching facilities [DEFAULT: "yes"]

Usage:

    edit.remove_line("/etc/sysctl.conf"){
        match = "net.ipv4.ip_forward = 1",
        plain = true
    }
generated by LDoc 1.4.6 Last updated 2017-05-09 15:50:38