Skip to content

Instantly share code, notes, and snippets.

@chriseppstein
Forked from markbrown4/awk-scss-mod.md
Last active March 16, 2018 17:34
Show Gist options
  • Save chriseppstein/57ca98ccefd642ce009d50f45998774d to your computer and use it in GitHub Desktop.
Save chriseppstein/57ca98ccefd642ce009d50f45998774d to your computer and use it in GitHub Desktop.
{
  line = $0
  while (match(line, /^(.*)spacing\(([0-9\.]+)\)(.*)$/, groups)) {
    line = groups[1] "SPACING(" (groups[2] * 2) ")" groups[3]
  }
  gsub(/SPACING/, "spacing", line)
  print line
}
@markbrown4
Copy link

markbrown4 commented Mar 16, 2018

Amazing! Thanks :)

This works for executing it on all .scss files in the current directory.

find ./ -type f -name "*.scss" | xargs gawk -i inplace '{                                                          
  line = $0
  while (match(line, /^(.*)spacing\(([0-9\.]+)\)(.*)$/, groups)) {
    line = groups[1] "SPACING(" (groups[2] * 2) ")" groups[3]
  }
  gsub(/SPACING/, "spacing", line)
  print line
}'

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