我正在从 .txt 文件中获取行:
说输入.txt
a
*
b
然后我正在阅读它:
#!/bin/bash
file=$1
ans=0
while read -r line || [[ -n "$line" ]]
do
echo $line
done < $file # passing the file
我得到以下输出
a
test main.py sic.sh
b
显示我目录中的文件而不是 *
我想根据需要检测/读取 * 的 * char 做出一些决定?
始终引用变量:
#!/bin/bash
file="$1"
ans=0
while read -r line || [[ -n "$line" ]]
do
echo "$line"
done < "$file" # passing the file
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)