Read a file line by line assigning the value to a variable

后端 未结 10 1184
说谎
说谎 2020-11-21 07:37

I have the following .txt file:

Marco
Paolo
Antonio

I want to read it line-by-line, and for each

10条回答
  •  不要未来只要你来
    2020-11-21 08:11

    For proper error handling:

    #!/bin/bash
    
    set -Ee    
    trap "echo error" EXIT    
    test -e ${FILENAME} || exit
    while read -r line
    do
        echo ${line}
    done < ${FILENAME}
    

提交回复
热议问题