Skip to content

Instantly share code, notes, and snippets.

@PhilippeVay
Created November 17, 2017 11:14
Show Gist options
  • Save PhilippeVay/637a578a10d72de70fe30649607386fd to your computer and use it in GitHub Desktop.
Save PhilippeVay/637a578a10d72de70fe30649607386fd to your computer and use it in GitHub Desktop.
SVG parsing: display viewBox dimensions
# In a directory full of SVG files, extract and display values of their viewBox
# 1/2 Rough display
grep -H -o -i --color -E 'viewbox="([0-9. ]+)?"' *.svg
# Output:
# uEA01-arrow-down.svg:viewBox="0 0 50 50"
# uEA02-arrow-left.svg:viewBox="0 0 50 50"
# 2/2 Better display (no more color highlighting with Git Bash on Win 10 though)
grep -HoiE --color 'viewbox="([0-9. ]+)?"' *.svg | awk -F '[:"]' '{ print $1 " => \"" $3 "\"" }'
# Output:
# uEA01-arrow-down.svg => "0 0 50 50"
# uEA02-arrow-left.svg => "0 0 50 50"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment