Shell loops using non-integers?

后端 未结 6 1791
悲哀的现实
悲哀的现实 2021-02-01 22:05

I wrote a .sh file to compile and run a few programs for a homework assignment. I have a \"for\" loop in the script, but it won\'t work unless I use only integers:



        
6条回答
  •  悲哀的现实
    2021-02-01 22:41

    Here's another way. You can use a here doc to include your data in the script:

    read -r -d '' data <

    Similarly:

    array=(
    1.1
    2.12
    3.14159
    4
    5.05
    )
    
    for i in "${array[@]}"
    do
        ./hw3_2_2 "$i"
    done
    

提交回复
热议问题