Bash脚本:我需要将wc -l的输出与变量进行比较 - 以匹配大于或等于该变量。以下代码不起作用,但显示了我想要做的事情。
wc -l
#!/bin/bash minimum_finds=1 found=$(locate this_is_the_file_i_want.txt|wc -l) if [[ $found >= $minimum_finds ]]; then echo "Minimum met" fi
请使用简洁和现代的bash:
if ((found >= minimum_finds)); then
检查bash arithmetic
用>=替换-ge(大于或等于)
>=
-ge
见:help test
help test