diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2024-07-27 17:54:52 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2024-07-27 17:54:52 -0300 |
commit | 4ec2ccefc35e250650f702e08b1c916d112761a8 (patch) | |
tree | 39889344c2842e1f17147cf0555ad450e15511b1 | |
parent | 9e2ce95bc99977bf47c9cfbe3489440cdd3418d7 (diff) | |
download | scripts-4ec2ccefc35e250650f702e08b1c916d112761a8.tar.gz scripts-4ec2ccefc35e250650f702e08b1c916d112761a8.tar.bz2 |
Feat: collector: count action
-rwxr-xr-x | collector | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -9,6 +9,7 @@ # Parameters BASENAME="`basename $0`" ACTION="$1" +COLLECTOR_NAME="`echo $COLLECTOR_FILE | sed -e "s|$HOME|~|"`" # Check if [ -z "$COLLECTOR_FILE" ]; then @@ -30,13 +31,17 @@ elif [ "$ACTION" == "add" ]; then echo "* $*" >> "$COLLECTOR_FILE" elif [ "$ACTION" == "list" ]; then if grep -q -e "^ *\* " "$COLLECTOR_FILE"; then - COLLECTOR_NAME="`echo $COLLECTOR_FILE | sed -e "s|$HOME|~|"`" - echo "Collected items at $COLLECTOR_NAME:" echo "" grep -e "^ *\* " "$COLLECTOR_FILE" echo "" fi +elif [ "$ACTION" == "count" ]; then + if grep -q -e "^ *\* " "$COLLECTOR_FILE"; then + COUNT="`grep -e "^ *\* " "$COLLECTOR_FILE" | wc -l`" + echo "$COUNT collected items at $COLLECTOR_NAME" + echo "" + fi elif [ "$ACTION" == "edit" ]; then if [ ! -z "$EDITOR" ]; then $EDITOR "$COLLECTOR_FILE" |