Skip to content

Instantly share code, notes, and snippets.

@jessuppi
Last active August 6, 2020 18:47
Show Gist options
  • Select an option

  • Save jessuppi/53880a878b4615e4353a60adf7d58ca9 to your computer and use it in GitHub Desktop.

Select an option

Save jessuppi/53880a878b4615e4353a60adf7d58ca9 to your computer and use it in GitHub Desktop.
Complex Sed Replace Examples
## fix hyperlinks (but not media src as they are shared with production uploads folder) ##
# sed 's#href="https://$SITE_DOMAIN#href="https://$SITE_DOMAIN/staging#g' /tmp/staging.sql
# sed 's#href="http://$SITE_DOMAIN#href="https://$SITE_DOMAIN/staging#g' /tmp/staging.sql
# sed 's#href="//$SITE_DOMAIN#href="https://$SITE_DOMAIN/staging#g' /tmp/staging.sql
# sed "s#href='https://$SITE_DOMAIN#href='https://$SITE_DOMAIN/staging#g" /tmp/staging.sql
# sed "s#href='http://$SITE_DOMAIN#href='https://$SITE_DOMAIN/staging#g" /tmp/staging.sql
# sed "s#href='//$SITE_DOMAIN#href='https://$SITE_DOMAIN/staging#g" /tmp/staging.sql
## fix sources (mirrors to production uploads folder using Nginx alias so this is just for cleaner source code) ##
# sed 's#src="https://$SITE_DOMAIN#src="https://$SITE_DOMAIN/staging#g' /tmp/staging.sql
# sed 's#src="http://$SITE_DOMAIN#src="https://$SITE_DOMAIN/staging#g' /tmp/staging.sql
# sed 's#src="//$SITE_DOMAIN#src="https://$SITE_DOMAIN/staging#g' /tmp/staging.sql
# sed "s#src='https://$SITE_DOMAIN#src='https://$SITE_DOMAIN/staging#g" /tmp/staging.sql
# sed "s#src='http://$SITE_DOMAIN#src='https://$SITE_DOMAIN/staging#g" /tmp/staging.sql
# sed "s#src='//$SITE_DOMAIN#src='https://$SITE_DOMAIN/staging#g" /tmp/staging.sql
## copy salt keys from production to staging (enables permanent login on both production/staging) ##
# sed "/'AUTH_KEY'/c\\$PROD_AUTH_KEY" /var/www/html/staging/wp-config.php
# sed "/'SECURE_AUTH_KEY'/c\\$PROD_SECURE_AUTH_KEY" /var/www/html/staging/wp-config.php
# sed "/'LOGGED_IN_KEY'/c\\$PROD_LOGGED_IN_KEY" /var/www/html/staging/wp-config.php
# sed "/'NONCE_KEY'/c\\$PROD_NONCE_KEY" /var/www/html/staging/wp-config.php
# sed "/'AUTH_SALT'/c\\$PROD_AUTH_SALT" /var/www/html/staging/wp-config.php
# sed "/'SECURE_AUTH_SALT'/c\\$PROD_SECURE_AUTH_SALT" /var/www/html/staging/wp-config.php
# sed "/'LOGGED_IN_SALT'/c\\$PROD_LOGGED_IN_SALT" /var/www/html/staging/wp-config.php
# sed "/'NONCE_SALT'/c\\$PROD_NONCE_SALT" /var/www/html/staging/wp-config.php
# sed -n "#NONCE_SALT#c $PROD_NONCE_SALT#p" /var/www/html/staging/wp-config.php
@jessuppi
Copy link
Copy Markdown
Author

jessuppi commented Aug 6, 2020

Reserving first comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment