Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save graingert/bf23f6f4193679272307cc2c1ac1e763 to your computer and use it in GitHub Desktop.
Save graingert/bf23f6f4193679272307cc2c1ac1e763 to your computer and use it in GitHub Desktop.
regex replace multi-line + in multiple files
$FILES="*.rs"
$REGEX="s#(.*)\n(.*)/\2\n\1/"
find . -name "$FILES" | xargs perl -0777 -pi -e '$REGEX'
# flag: -0777 tells perl to read the file as a whole
# replace '-pi' with '-pi.bak' to create backups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment