在while循环内使用带有printf的grep吗?

GOAL: Needing to use the grep command to fileter the incoming/printed lines of data. Basically based on a user defined pattern, the script should be able to highlight a pattern from the incoming data provided by the while-loop/ printf command.

ISSUE: Whenever attempting to use grep the desired output is not recieved.Either the output seems to get staggered (placed on seperate lines) and no pattern is found.

为了解决这个问题,我提供了代码的主要受影响部分,即“ while循环”

while read dayst timst qty
do
        if (( qty > MAX ))
        then
                let MAX=$qty+$qty/4 # allow more room
                echo "          **** rescaling: MAX=$MAX"
        fi

        # need to grep the 'printf...' line of cmd

        printf '%6.6s %6.6s %4d:' $dayst $timst $qty 
        pr_bar $qty $MAX

done < <( if ! [[ -z $ON ]]; then bash killswitch.sh; elif [[ -z $ON ]] ; then bash tailcount.sh; fi )

输出(无grep操作):

200523 100110   10:##########
200523 100115    0:#
200523 100120    0:#

输出(使用grep操作):

200523 100502   10:
##########
200523 100507    0:
#
200523 100512    0:
#
评论