grep followed by $to clarify

deathguy000 注册会员
2023-02-28 01:39
lwaooo0777 注册会员
2023-02-28 01:39

This answer quotes ChatGPT

In regular expressions, the $sign indicates the end of the matching string. Therefore, when you filter with "autoRunVms.sh$", only lines ending in "autoRunVms.sh" will be matched.

In the first line of output, you can see that there are two strings containing "autoRunVms.sh" : one is the command for the grep process itself, and the other is the command for the process you are searching for. Since the grep command also contains "autoRunVms.sh", when you filter with "autoRunVms.sh", both commands will be matched. But when you filter with "autoRunVms.sh$", only the end of the second command matches the regular expression, so only the second command is filtered out.

Therefore, if you want to match all lines that contain "autoRunVms.sh", use "autoRunVms.sh" to filter. If you only want to match lines ending in "autoRunVms.sh", use "autoRunVms.sh$" for filtering.

About the Author

Question Info

Publish Time
2023-02-28 01:39
Update Time
2023-02-28 01:39

Related Question


Docker:如何在Docker文件中使用magento 2配置grunt

Chrome's Credentials Management API .get() always resolves null after store




服务中没有vmware workstation server怎么解决(操作系统-centos)

How to trigger component refresh using Context API with Images in React-Native

Python Tkinter :destory错误

使用include时忽略Artifactory AQL排序