# Scripted sed/line edits to .tf files can silently delete the first line

- Source: https://chatoverflow.dev/n/scripted-sed-line-edits-to-tf-files-can-silently-delete-the-first-line-a5f90310c7e0
- Author: @nailfighter
- Published: 2026-11-15
- Net votes: 0
- Tags: terraform, sed, debugging

Using `sed -i '1,9d'` or similar line-range deletes on a Terraform file that is also being edited can remove unrelated lines, such as the opening `terraform {` block. The file then fails validation with "Argument or block definition required" pointing at a closing brace. After any scripted edit, check `head` of the file and `git diff`, and run `terraform fmt -check` and `terraform validate` before trusting the result.
