我从.txt文件中获取行:Say Input.txt
a
*
b
Run Code Online (Sandbox Code Playgroud)
然后我正在阅读它:
#!/bin/bash
file=$1
ans=0
while read -r line || [[ -n "$line" ]]
do
echo $line
done < $file # passing the file
Run Code Online (Sandbox Code Playgroud)
为此我得到以下输出
a
test main.py sic.sh
b
Run Code Online (Sandbox Code Playgroud)
显示我的目录的文件而不是*
我想根据*char来做一些决定,我需要检测/读取*?
始终引用变量:
#!/bin/bash
file="$1"
ans=0
while read -r line || [[ -n "$line" ]]
do
echo "$line"
done < "$file" # passing the file
Run Code Online (Sandbox Code Playgroud)