Hello.
I am trying to modify a config file which is in windows *.ini type file.
I have found a piece of code here :linux - Edit file in unix using SED - Stack Overflow
As I can't make it doing the job , I am trying to find a solution step by step.
here a modified sample file : my_sample.ini for my first question
[handler_syncserver]
class = StreamHandler
args = (sys.stderr,)
level = INFO
formatter = generic
handler_syncserver_errors
class = handlers.RotatingFileHandler
args = ('/tmp/sync-error.log',)
level = ERROR
formatter = generic
[formatter_generic]
format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %Y-%m-%d %H:%M:%S
The first question is about range adress :
When I use this command :
sed -n /^handler_syncserver_errors/,/^$/p my_sample.ini
The correct range is printed on console screen :
handler_syncserver_errors
class = handlers.RotatingFileHandler
args = ('/tmp/sync-error.log',)
level = ERROR
formatter = generic
Now using the real sample file :
[handler_syncserver]
class = StreamHandler
args = (sys.stderr,)
level = INFO
formatter = generic
[handler_syncserver_errors]
class = handlers.RotatingFileHandler
args = ('/tmp/sync-error.log',)
level = ERROR
formatter = generic
[formatter_generic]
format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %Y-%m-%d %H:%M:%S
The modified command does not work, and remove all header section
sed -n /^\[handler_syncserver_errors\]/,/^$/p my_sample.ini
class = StreamHandler
args = (sys.stderr,)
level = INFO
formatter = generic
class = handlers.RotatingFileHandler
args = ('/tmp/sync-error.log',)
level = ERROR
formatter = generic
datefmt = %Y-%m-%d %H:%M:%SLINUX-TEST-123:/opt/firefox/favoris_sync/server-full #
Iam using sed on opensuse :
13.1 kernel 3.11.6-4-desktop #1 SMP PREEMPT Wed Oct 30 18:04:56 UTC 2013 (e6d4a27) x86_64 x86_64 x86_64 GNU/Linux
sed --version
sed (GNU sed) 4.2.2
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Jay Fenlason, Tom Lord, Ken Pizzini,
and Paolo Bonzini.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-sed@gnu.org>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
The second question will come after this one
Any help is welcome.
---------- Post updated at 18:19 ---------- Previous update was at 18:10 ----------
Found answer to first question here
Trouble with sed and ini file parsing | Unix Linux Forums | Shell Programming and Scripting
--> add single quote
sed -n '/^\[handler_syncserver_errors\]/,/^$/p' my_sample.ini