When getting an image's pixelWidth using SIPS it outputs with a heading. e.g.
sips -g pixelWidth $images
returns
" pixelWidth: 1920"
I'm trying to get the integer part only, with no luck:
sips -g pixelWidth $images | grep \d+$
Any Ideas?
You want to use grep's -E (regex) and -o (capture matches) flags, this works for me:
sips -g pixelWidth menu_icon.png | grep -Eo "\d+"
Note if you have any numbers in your file path to the image(s), they will show up (since sips prints the file path too), so you might want to add grep pixelWidth
before you grep out the number, like this:
sips -g pixelWidth menu_icon.png | grep pixelWidth | grep -Eo "\d+"