Issue
I have below command to get files and I want to exclude all .blade.php files.
$(git diff --cached --name-only --diff-filter=ACM | grep ".php\{0,1\}$")
How can I do that?
I tried these ways :
-
$(git diff --cached --name-only --diff-filter=ACM | grep --exclude="*\.blade.php*"| grep ".php\{0,1\}$")
-
$(git diff --cached --name-only --diff-filter=ACM | grep --exclude="*\.blade.php*" ".php\{0,1\}$")
but none of the above is working.
Solution
One is to use grep -v
to exclude files that match a pattern.
git diff --cached --name-only --diff-filter=ACM | grep ".php\{0,1\}$" | grep -v '.blade.php$'
The other is to exclude the files in git diff
.
git diff --cached --name-only --diff-filter=ACM -- . ':!*.blade.php' | grep ".php\{0,1\}$"
-- . ':!*.blade.php'
means all files excluding those that match the pattern *.blade.php
under the current folder.
Answered By - ElpieKay Answer Checked By - Willingham (WPSolving Volunteer)