Bash script does not continue to read the next line of file

前端 未结 5 611
南笙
南笙 2021-02-06 17:27

I have a shell script that saves the output of a command that is executed to a CSV file. It reads the command it has to execute from a shell script which is in this format:

5条回答
  •  一个人的身影
    2021-02-06 18:08

    I think that should do the same and seems to be correct:

    #!/bin/bash
    
    CSVFILE=/tmp/file.csv
    
    cat "$@" | while read line; do
        echo "Executing '$line'"
        START=$(date +%s)
        eval $line &> /dev/null
        END=$(date +%s)
        let DIFF=$END-$START
    
        echo "$line, $START, $END, $DIFF" >> "$CSVFILE"
        echo "It took ${DIFF}s"
    done
    

    no?

提交回复
热议问题