Skip to content

Instantly share code, notes, and snippets.

@spikegrobstein
Last active April 3, 2017 16:07
Show Gist options
  • Save spikegrobstein/9f099b14b0869081fe976a444fe50e26 to your computer and use it in GitHub Desktop.
Save spikegrobstein/9f099b14b0869081fe976a444fe50e26 to your computer and use it in GitHub Desktop.
creates a histogram of the years of your media (assumes filename in the format of "Title (YYYY)")
#! /usr/bin/env bash
IFS=$'\n'
media_directory=$1
if [[ -z "$media_directory" ]]; then
echo "Usage: $0 <media-directory>"
exit 1
fi
ls "$media_directory" \
| grep -o -E '\([[:digit:]]{4}\)$' \
| sort \
| uniq -c \
| while read line; do
count=$( awk '{ print $1 }' <<< "$line" )
year=$( echo "$line" | awk '{ print $2 }' | grep -o -E '[[:digit:]]+')
printf "$year "
printf "*%.0s" $( seq 1 "$count" )
printf "\n"
done
1922 **
1924 *
1926 *
1927 *
1928 **
1931 ***
1932 ***
1934 *
1935 *
1936 **
1937 **
1939 ***
1940 **
1941 ***
1942 ***
1944 *
1945 *
1946 ***
1947 *
1948 **
1949 *
1950 **
1951 *****
1953 ****
1954 ****
1955 **
1956 ****
1957 *****
1958 *******
1959 *****
1960 ******
1961 ******
1962 ****
1963 *********
1964 ************
1965 ******
1966 ********
1967 *********
1968 ******
1969 **
1970 ******
1971 *****************
1972 **************
1973 ***********
1974 *****************
1975 *********
1976 ******************
1977 ****************
1978 ****************
1979 *****************
1980 **********************
1981 ****************************
1982 **********************************
1983 **************************
1984 *******************************************
1985 ********************************************
1986 ****************************************
1987 ****************************************
1988 **********************************************************
1989 ***************************************************
1990 ************************************
1991 *********************************
1992 **************************************
1993 *****************************
1994 ****************************************
1995 ***************************
1996 *******************************
1997 *****************************
1998 ****************************
1999 **********************************
2000 *************************
2001 **********************************
2002 **********************************
2003 *******************
2004 ******************************
2005 *********************************
2006 ******************************
2007 ************************************
2008 ****************************
2009 *****************************
2010 *******************************
2011 ***************************
2012 *************************
2013 ****************************************************
2014 ****************************************
2015 ******************************************************
2016 ************************************
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment