I'm using git diff to return the file names of files recently changed and i'm trying to pipe the returned file names into a grep expression that searches each file and returns the files that have "*.yml" in the file name and "- name:" in the actual file. However it seems like my code only returns all the files in the directory that match the conditions, basically ignoring the git diff.
files=($(git -C ${dir} diff --name-only HEAD^ HEAD | grep -rlw --include="*.yml" --exclude-dir=$excluded_paths-e "- name:"))
Any help would appreciated!
git -C ${dir} diff --name-only HEAD^ HEAD
, the output of the complete pipegit -C ${dir} diff --name-only HEAD^ HEAD | grep -rlw --include="*.yml" --exclude-dir=$excluded_paths-e "- name:"
and add the expected result. Make sure to copy&paste exactly the command you run on your system. Variable expansions should be quoted--exclude-dir="$excluded_paths"
and there must be a space between this and-e
.