Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

grep 每个换行算1行,能不能以分号结束算1行呢?

例如查找mysql的binlog,它是以分号算作一条的。grep默认是换行算一条。那就截断了。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

echo "11;12;21" | sed 's/;/ /g' | grep 2
OR
echo "11;12;21" | awk 'BEGIN{FS=";"} {print $0}' | grep 2


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...