Skip to content

Sed-related

🛠️ Tools · ⬅ Top


sedReplacePattern

Quote a sed command for search and replace

Usage

sedReplacePattern searchPattern replacePattern

Quote a sed command for search and replace Without arguments, displays help.

Arguments

  • searchPattern - Required. String. The string to search for.
  • replacePattern - Required. String. The replacement to replace with.

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

quoteSedPattern

Quote sed search strings for shell use

Usage

quoteSedPattern text

Quote a string to be used in a sed pattern on the command line.

Arguments

  • text - EmptyString. Required. Text to quote

Examples

sed "s/$(quoteSedPattern "$1")/$(quoteSedPattern "$2")/g"
needSlash=$(quoteSedPattern '$.*/[\]^')

Sample Output

string quoted and appropriate to insert in a sed search or replacement phrase

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

Requires

printf sed usageDocument __help

quoteSedReplacement

Quote sed replacement strings for shell use

Usage

quoteSedReplacement text separatorChar

Quote sed replacement strings for shell use

Arguments

  • text - EmptyString. Required. Text to quote
  • separatorChar - The character used to separate the sed pattern and replacement. Defaults to /.

Examples

sed "s/$(quoteSedPattern "$1")/$(quoteSedReplacement "$2")/g"
needSlash=$(quoteSedPattern '$.*/[\]^')

Sample Output

string quoted and appropriate to insert in a sed replacement phrase

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

Requires

printf sed usageDocument __help