#!/bin/bash use_defs="yes" def_lim="New" while getopts ":hn:p:" opts; do case $opts in h ) echo "mpfind is a simple script to make it simple to deal with mpd" echo "The only options for it are as follows:" echo "-h :: This help output" echo "-n :: Remove entries that match from the results" echo "-p :: Search within known playlist for " exit 0;; n ) limit=$OPTARG;; p ) playlist=$OPTARG;; * ) echo "Please supply a valid arguement to mpfind." echo "The only options for it are as follows:" echo "-h :: The help file" echo "-n :: Remove entries that match from the results" echo "-p :: Search within known playlist for " exit 1;; esac done shift $(($OPTIND -1)) if [ $playlist ]; then excommand="mpc lsplaylists | sed -n -e '/$playlist/p'" else excommand="mpc listall" fi if [ $limit ]; then excommand="$excommand | sed -e '/$limit/d'" else if [ "$use_defs" = "yes" -a -z "$playlist" ]; then excommand="$excommand | sed -e '/$def_lim/d'" fi fi for entry; do excommand="$excommand | sed -n -e '/$entry/p'" done eval "$excommand"