Skip to content

Instantly share code, notes, and snippets.

@wilfm
wilfm / grephexcolourcode
Created September 14, 2015 17:54
Grep Hex Colour Codes from file
#!/bin/bash
#get hex codes in form #fff and #ffffff
#checks to see if not - especially needed on #fff matches
#FIXME: - currently prints trailing character
if [[ ! -a $1 ]]; then
echo File not found
exit 1
fi
sed ':a;N;$!ba;s/\n/ /g' "$1" | grep -o '\#[0-9a-fA-F]\{3\}[^0-9a-fA-F]' | sed 's/[^0-9a-fA-F#]//g' | sort -u