从bash文件中读取星号字符(*) [英] Reading asterisk character (*) from a file in bash
本文介绍了从bash文件中读取星号字符(*)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在从.txt文件中提取行:说出Input.txt
I am taking lines from a .txt file: 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
显示我目录的文件而不是*
Where files of my directory are being shown instead of *
我想根据需要检测/读取*的* char做出一些决定?
I want to take some decisions on the basis of * char for which I need to detect/read * ?
推荐答案
始终引用变量:
#!/bin/bash
file="$1"
ans=0
while read -r line || [[ -n "$line" ]]
do
echo "$line"
done < "$file" # passing the file
这篇关于从bash文件中读取星号字符(*)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文