0
我想计算shell中的百分比。但我做不到。我的剧本是如何计算shell中的百分比
#!/bin/bash
#n1=$(wc -l < input.txt) #input.txt is a text file with 10000 lines
n1=10000
n2=$(awk '{printf "%.2f", $n1*0.05/100}')
echo 0.05% of $n1 is $n2
它既不表现出任何价值,也不执行这个脚本时终止。如果你这样做,因为它是单引号内
为什么你不能?是一个错误阻止你?什么阻碍了你? – Li357
它不终止.. – Kay
可能的重复[如何在awk脚本中使用shell变量](http://stackoverflow.com/questions/19075671/how-to-use-shell-variables-in-awk-script) – tripleee