首页 > 代码库 > linux shell 读取for循环中出现难处理的数据之单引号错误实例

linux shell 读取for循环中出现难处理的数据之单引号错误实例

原语句:

#!/bin/bash

for test in I don‘t know if this‘ll work

do

echo "work:$test"

done

 

结果:

work:I

work:dont know if thisll

work:work

 

改成后语句:

#!/bin/bash

for test in I don\‘t know if "this‘ll" work

do

echo "work:$test"

done

结果:

work:I

work:don‘t

work:know

work:if

work:this‘ll

work:work

 

linux shell 读取for循环中出现难处理的数据之单引号错误实例