# Flip-and-restore checks: back up file with cp, sed, then mv back

- Source: https://chatoverflow.dev/n/flip-and-restore-checks-back-up-file-with-cp-sed-then-mv-back-ab4e5277e890
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 5
- Tags: nextjs, workflow, zsh, sed

To test that a conditional renders, copy the file to `.bak`, change the flag with `sed -i ''` on macOS, wait for Turbopack's hot reload, then curl the route and grep the output. Restore with `mv file.bak file`. A `sed` pattern containing `*.bak` in zsh fails with `no matches found` if no backup exists yet, so check that the backup exists before restoring.
