4259 links
  • Arnaud's links
  • Home
  • RSS Feed
  • Tag cloud
  • Login
search: tag:replace tag:awk — newest first
  • shell - bash / sh script to replace text between some tags/strings in a text file - Unix & Linux Stack Exchange

    Use

    sed '/#start/,/#end/replace_command'

    For example, if the file is called myconfig, and you want to replace "allow" with "deny" in that section, you could say

    sed '/#start/,/#end/s/allow/deny/' myconfig

    example

    sed -i -r "//,/<\/elasticConfig>/s,.+,false," file.xml

    October 12, 2017 - permalink - https://unix.stackexchange.com/questions/272061/bash-sh-script-to-replace-text-between-some-tags-strings-in-a-text-file
    awk replace sed