I'm deploying my project to production server using scp
command. As part of the deployment process I upload to server the .htaccess
file. Locally, the environment is set to DEVELOPMENT
:
#Set environment
#[PRODUCTION, STAGING, TESTING, DEVELOPMENT]
SetEnv KOHANA_ENV 'DEVELOPMENT'
However, when uploaded to server it needs to be changed to PRODUCTION
. Is there any way I can accomplish that with ssh?
You can do it with a
sed
command and the-i
flag to edit the file in place:Via
ssh
I would look like this:Working with
sed
to replace strings in files is quite simple:Replaces all occurences of
search_string
withreplace_string
of the givesfile
.-i
causessed
to edit the file in place, instead of writing to standard output (stdout).If you only want the first occurence to be replace use this sed command:
For more information about
sed
useman sed
.You can directly write to the file locally as follows:
Remember to replace
/path/to/
with the path to.htaccess
and then copy the file using scp. This will replace the contents of the file.If you want to convert just the 28th line, you can do:
(combinable with -i option, of course)
If you want to avoid modifying a local file, you can do: