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.
我想对里面有双引号的关键字做 grep。举一个简单的例子:
echo "member":"time" | grep -e "member\""
那不匹配。我该如何解决?
问题是您没有正确转义输入字符串,请尝试:
echo "\"member\":\"time\"" | grep -e "member\""
或者,您可以在单引号内使用未转义的双引号:
echo '"member":"time"' | grep -e 'member"'
尽管第二种方法会阻止您将命令嵌套在另一组单引号中(例如ssh 'cmd'),但您会发现这是一个更清楚的偏好问题。
ssh 'cmd'