How to do replace using sed only in one section of file

arheops

File looks like this:

[section1]
a=something
[section_name2]
a=something
[section3]
a=something

How do I replace a=someother only in section_name2?

choroba

Use an address range:

sed '/\[section_name2\]/,/^\[/ s/a=something/a=someother/'

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to replace values in a file using sed

分類Dev

How to replace a xml file line using sed

分類Dev

How to replace one line with two lines using sed in csh on BSD?

分類Dev

sed - capture a group and replace only one character

分類Dev

using Sed to find and replace a string inside a file

分類Dev

bash: how to source array from section config file after sed?

分類Dev

How to replace value with square brackets using sed?

分類Dev

How can I replace a filename with .ear in a file-list using sed?

分類Dev

Replace text in file with SED

分類Dev

Find and replace a character in xml file using sed command is not working

分類Dev

How to use gnu sed to replace all but one word?

分類Dev

How do you filter a file input so that it only shows one type of file?

分類Dev

How to replace an email in a (PHP) file from the command line without sed?

分類Dev

How to use variable in sed command to replace a property value in a property file

分類Dev

How to replace the first match only using .Net Regex.Replace

分類Dev

How can I replace a newline (\n) using sed?

分類Dev

How to find & replace pattern WITHIN specific pattern using sed

分類Dev

Sed replace specific line in file

分類Dev

Sed replace specific line in file

分類Dev

sed command - Replace string in file

分類Dev

How to replace one character with mutliple characters using search and replace in vim

分類Dev

How change only one parameter in file

分類Dev

How to include stylesheet file only for one div?

分類Dev

Use Sed Regex Capture Group in Replace Section Method

分類Dev

Inline search and replace using sed

分類Dev

How to cherry pick only changes for only one file, not the whole commit

分類Dev

sed - Function to replace only the NTH occurrence

分類Dev

sed + replace only the second match word

分類Dev

how to use sed to replace the specific line/lines in a file with the contents from another file

Related 関連記事

  1. 1

    How to replace values in a file using sed

  2. 2

    How to replace a xml file line using sed

  3. 3

    How to replace one line with two lines using sed in csh on BSD?

  4. 4

    sed - capture a group and replace only one character

  5. 5

    using Sed to find and replace a string inside a file

  6. 6

    bash: how to source array from section config file after sed?

  7. 7

    How to replace value with square brackets using sed?

  8. 8

    How can I replace a filename with .ear in a file-list using sed?

  9. 9

    Replace text in file with SED

  10. 10

    Find and replace a character in xml file using sed command is not working

  11. 11

    How to use gnu sed to replace all but one word?

  12. 12

    How do you filter a file input so that it only shows one type of file?

  13. 13

    How to replace an email in a (PHP) file from the command line without sed?

  14. 14

    How to use variable in sed command to replace a property value in a property file

  15. 15

    How to replace the first match only using .Net Regex.Replace

  16. 16

    How can I replace a newline (\n) using sed?

  17. 17

    How to find & replace pattern WITHIN specific pattern using sed

  18. 18

    Sed replace specific line in file

  19. 19

    Sed replace specific line in file

  20. 20

    sed command - Replace string in file

  21. 21

    How to replace one character with mutliple characters using search and replace in vim

  22. 22

    How change only one parameter in file

  23. 23

    How to include stylesheet file only for one div?

  24. 24

    Use Sed Regex Capture Group in Replace Section Method

  25. 25

    Inline search and replace using sed

  26. 26

    How to cherry pick only changes for only one file, not the whole commit

  27. 27

    sed - Function to replace only the NTH occurrence

  28. 28

    sed + replace only the second match word

  29. 29

    how to use sed to replace the specific line/lines in a file with the contents from another file

ホットタグ

アーカイブ