我想检查我的变量是否具有这种格式--- foobar---> <some other stuff>
换句话说,我想知道文本是否以--- foobar --->
所以我使用grep -q
但得到了这个错误:
$echo "--- foobar---> subtree " | grep -q "--- fooobar--->*"
grep: unrecognized option `--- fooobar--->*'
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
(这是OSX
,和grep's version is:
$ grep --v
grep (GNU grep) 2.5.1
Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
)
如何重写我的正则表达式以匹配预期的字符串?
谢谢。