Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用以下代码对“1-10”、“10-20”、“1-9”(不带双引号)之类的模式进行 grep:
grep '[[:digit:]]\-[[:digit:]]' mydoc
可以 grep "1-9" 但我不知道如何 grep 其他两种模式!
减号不需要掩蔽。+ 允许多次出现。
egrep '[0-9]+-[0-9]+' mydoc
grep -E '[[:digit:]]+-[[:digit:]]+' mydoc
grep -E '[[:digit:]]{1,2}-[[:digit:]]{1,2}' mydoc
?