簡體   English   中英

如何在 shell 腳本內的字符串中添加正則表達式?

[英]How to add REGEX in a string inside a shell script?

以下命令檢測 git 中的任何暫存文件是否為myFile.js

echo $(git diff --cached --name-only --diff-filter=ACM | egrep 'path/to/myFile.jsx?$')

但我想檢測該文件夾中的任何.js文件。 我試過了,但沒有用:

echo $(git diff --cached --name-only --diff-filter=ACM | egrep 'path/to/{*}.jsx?$')

如何在此處為文件名添加通配符?

代替:

egrep 'path/to/{*}.jsx?$'

和:

egrep 'path/to/.+\.jsx?$'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM