在bash中,我需要检查一个字符串是否以'#'符号开头。我该怎么做?
这是我的做法--
这是我的做法--
if [[ $line =~ '#*' ]]; then
echo "$line starts with #" ;
fi
我想在一个文件上运行这个脚本,文件看起来像这样--
03930
#90329
43929
#39839
这是我的脚本 --
while read line ; do
if [[ $line =~ '#*' ]]; then
echo "$line starts with #" ;
fi
done < data.in
这是我期望的输出 --
#90329 starts with #
#39839 starts with #
但是我无法让它工作,有什么想法吗?