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
「1-9」を grep することはできますが、他の 2 つのパターンを grep する方法がわかりません!
マイナスはマスキング不要です。+ は複数回の出現を許可します。
egrep '[0-9]+-[0-9]+' mydoc
grep -E '[[:digit:]]+-[[:digit:]]+' mydoc
grep -E '[[:digit:]]{1,2}-[[:digit:]]{1,2}' mydoc
?