正在从bash中的文件中读取星号字符(*)

  • 本文关键字:字符 文件 bash 读取 bash
  • 更新时间 :
  • 英文 :


我正在从.txt文件中提取行:Say Input.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

显示我目录中的文件而不是*的位置

我想在需要检测/读取的*字符的基础上做出一些决定*?

始终引用变量:

#!/bin/bash
file="$1"
ans=0
while  read -r line || [[ -n "$line" ]]
do
echo "$line"
done < "$file" # passing the file

最新更新