0

After executing this script, sometimes the output looks like this:

1912:!    total e
ergy              = -1090.13343774 Ry
2310:!    total e
ergy              = -1090.20757070 Ry
2709:!    total e
ergy              = -1090.24296462 Ry
3084:!    total e
ergy              = -1090.25563488 Ry
3483:!    total e
ergy              = -1090.27085564 Ry
3870:!    total e
ergy              = -1090.27693129 Ry
4245:!    total e
ergy              = -1090.28213580 Ry
4632:!    total e
ergy              = -1090.29131927 Ry

and sometimes like this:

1912:!    total energy              = -1090.13343774 Ry
2310:!    total energy              = -1090.20757070 Ry
2709:!    total energy              = -1090.24296462 Ry
3084:!    total energy              = -1090.25563488 Ry
3483:!    total energy              = -1090.27085564 Ry
3870:!    total energy              = -1090.27693129 Ry
4245:!    total energy              = -1090.28213580 Ry

Is it just a bug or do I change something in the code unintentionally ?

The code:

cm=$1
nm=$2
case $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
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.