#!/bin/bash
DATE=`date +%Y-%m-%d`
HOUR=`date +%H`
ORDERS_THIS_HOUR=`cat cli.log | grep $DATE $HOUR | grep -o "generated for Production" | wc -l`
OUTPUT="$DATE $HOUR : $ORDERS_THIS_HOUR"
echo "$OUTPUT" >> flow_productivity.log
Issue is with the second line: grep: 14: No such file or directory.
Here is a sample command, the results of which I would like to store in $ORDERS_THIS_HOUR:
cat cli.log | grep "2019-02-13 12" | grep -o "generated for Production" | wc -l
Run from the command line, the above produces the expected output.
grep "$DATE $HOUR". Quotes are important.cat, and make itgrep "$DATE $HOUR" <cli.loggrep -Ec "$DATE $HOUR.*generated for Production" <cli.log, collapsing the pipeline to just one command; no more FIFOs at all.