After executing this script, sometimes the output looks like this:1912:!    total eergy              = -1090.13343774 Ry2310:!    total eergy              = -1090.20757070 Ry2709:!    total eergy              = -1090.24296462 Ry3084:!    total eergy              = -1090.25563488 Ry3483:!    total eergy              = -1090.27085564 Ry3870:!    total eergy              = -1090.27693129 Ry4245:!    total eergy              = -1090.28213580 Ry4632:!    total eergy              = -1090.29131927 Ryand sometimes like this:1912:!    total energy              = -1090.13343774 Ry2310:!    total energy              = -1090.20757070 Ry2709:!    total energy              = -1090.24296462 Ry3084:!    total energy              = -1090.25563488 Ry3483:!    total energy              = -1090.27085564 Ry3870:!    total energy              = -1090.27693129 Ry4245:!    total energy              = -1090.28213580 RyIs it just a bug or do I change something in the code unintentionally ?The code:cm=$1nm=$2case $cm in    out)        declare -a  en        ec=$(grep -n !  hw1_out_si_wire.txt)        IFS='\n' en=($ec)        for i in ${en[@]}        do            echo $i        done        ;;    in) echo It's not my problem;;esac
Why does the output look like different?
shell script;array
IFS='\n' sets the internal field separator to consist of two characters: \ (backslash) and the letter n. Use IFS=$'\n' instead which sets it to contain the newline only.