commandbox.system.modules_app.system-commands.commands

Class sed

lucee.Component
    extended by commandbox.system.modules_app.system-commands.commands.sed

Stream editor command for manipulating text one line at a time. Sed is similar to the many Unix implementations, but only supports the "s" command (substitute) currently. Pass or pipe the text to process or a filename along with the --file flag. . {code:bash} sed "hello world" s/hello/goodbye/ Outputs: "goodbye world" {code} . The substitute command syntax is "s/replaceMe/withMe/" where "s" is the command, "replaceMe" is a CFML regular expression, and "withMe" is a replacement expression. . Supported pattern flags are "g" (global) which replaces all instances per line, and "i" (ignore case) which makes the replacement case-insensitive. . {code:bash} echo "one hundred and one" | sed s/ONE/two/gi Outputs: "two hundred and two" {code} . All other regex rules follow what is implemented in REReplace() CFML function. . The delimiter in the subsdtitute command does not have to be "/". Whatever character that immediatley follows the "s" will be used. This can be useful where the regex and/or replacement text contain a "/". . This example uses a tilde (~) as the delimiter. It reads a file, replaces all instances of a given file path, and writes the file back out. . {code:bash} sed --file config.cfm s~/var/www/~/sites/wwwroot/~i > config.cfm {code}

Class Attributes:
  • synchronized : false
  •  
  • accessors : false
  •  
  • persistent : false
  •  
    Property Summary
    type property default serializable required
    any parser


    • access = public
    • returntype = any
    • inject = Parser
    true false
    Method Summary
    private any parseCommandParts([any command])
    private any parseFlags([any flags])
    any run(string inputOrFile, string commands, [boolean file='false'])
    private any substitute([any inputLines], [any command])
     
    Methods inherited from class lucee.Component
    None

    Property Detail

    parser

    property any parser

    Attributes:
    access - public
    required - false
    returntype - any
    inject - Parser
    serializable - true

    Method Detail

    parseCommandParts

    private any parseCommandParts([any command])

    Parameters:
    command

    parseFlags

    private any parseFlags([any flags])

    Parameters:
    flags

    run

    public any run(string inputOrFile, string commands, [boolean file='false'])

    Parameters:
    inputOrFile - The text to process, or a file name to read with --file
    commands - The command to perform on the input text. Ex: s/replaceMe/withMe/g
    file - Treat the input as a file path to read.

    substitute

    private any substitute([any inputLines], [any command])

    Parameters:
    inputLines
    command