I have the following shell script:
#!/bin/sh echo "Configuring Xdebug" ip=10.0.2.2 xdebug_config="/etc/php/7.2/mods-available/xdebug.ini" echo "IP for the xdebug to connect back: ${ip}" echo "Xdebug Configuration path: ${xdebug_config}" echo "Port for the Xdebug to connect back: ${XDEBUG_PORT}" echo "Optimize for ${IDE} ide" if [ $IDE=='atom' ]; then echo "Configuring xdebug for ATOM ide" config="xdebug.remote_enable = 1 xdebug.remote_host=${ip} xdebug.remote_port = ${XDEBUG_PORT} xdebug.max_nesting_level = 1000 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_autostart=true xdebug.remote_log=xdebug.log" # replace the file in $xdebug_config var except first line fi What I want is to replace the first line in the file mentioned in $xdebug_config variable EXCEPT the first line. For example if the file is:
line 1 line 2 somethig else lalala I want to get converted like that:
line 1 xdebug.remote_enable = 1 xdebug.remote_host=${ip} xdebug.remote_port = ${XDEBUG_PORT} xdebug.max_nesting_level = 1000 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_autostart=true xdebug.remote_log=xdebug.log How I can achieve that?
Edit 1
As requested on the comments the $xdebug_config can contain theese possible values:
/etc/php/7.2/mods-available/xdebug.ini /etc/php/5.6/mods-available/xdebug.ini /etc/php/7.0/mods-available/xdebug.ini Generally it will be in the following format:
/etc/php/^number^.^number^/mods-available/xdebug.ini Edit 2
I perfected the shell script in order to be more clear.
$xdebug_configin the question? This will make things much clearer. Currently, what you want is not clear, you had mentioned in the questionWhat I want is to replace the first line in the file mentioned in $xdebug_config variable EXCEPT the first line.this is completely unclear.head -n1and then write out the rest according to what you want?[ $IDE=='atom' ]-- paste your code into shellcheck.net for more details.