dos2unix

怼。。。。。。。。。。

写了半天一个统计脚本到linux下报错  :D
-bash: ./count_api.sh: /bin/bash^M: bad interpreter: 没有那个文件或目录

想到换行win下 \r\n 与linux \n 不同,再想有转换的命令 dos2unix,转换一下世界安静了。

#dos2unix count_api.sh

dos2unix: converting file count_api.sh to UNIX format ...

#./count_api.sh



-------------------------------------------------------

附上脚本, 因为 bash没有二维数组,所以用其他方式来实现

#!/bin/bash

h62=(23 5 56 64 56)
h63=(2 22 88 99 7 3)
h64=(12 67 89 30 29)
h65=(26 27 28 29 30)
h66=(32 65 69 13 19 85)

host="62 63 64 65 66"

for myhost in $host
do
    echo $myhost
    echo '---------------------------------'
    eval tmp=\${h${myhost}[@]}
    for myapi in ${tmp}
    do
        echo ${myapi}
    done
done


你可能感兴趣的:(dos2unix)