Advertisement
Guest User

Untitled

a guest
Mar 12th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. [sectionA]
  2. url = value1
  3. username = value2
  4. password = value3
  5.  
  6. [sectionC]
  7. url = value1
  8. username = value2
  9. password = value3
  10.  
  11. [sectionB]
  12. url = value1
  13. username = value2
  14. password = value3
  15.  
  16. sed '/sectionB/,/[/s/username.*/username = valueX/' input
  17.  
  18. awk -vRS='' -vFS='n' -vOFS='n' '
  19. $1~/sectionB/{
  20. sub(/=.*$/, "= valueX", $3)
  21. }
  22. {
  23. printf "%snn", $0
  24. }' input
  25.  
  26. sed -E -n '1h;1!H;${;g;s/[sectionB]([^[]*)username = [a-zA-Z0-9_]+/[sectionB]1username = valueX/g;p;}' input.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement