1

I have a list of files using:

$git show commit:.data/path/to/file/

abc-2018-q1.csv
def-2019-q2.csv
the-2019-q1.csv

I am trying to do $git show commit:.data/path/to/file/ | grep *q1*

ie select only those files whose names contain "q1". However the step the step does not give any result.

How can I get the desired files containing "q1".

2
  • 2
    grep expects a regex, not a wildcard (and moreover, when you don't quote your argument, it's evaluated by the shell as a glob expression before grep even sees it). You want something like git show commit:.data/path/to/file | grep -e 'q1'. Mar 18, 2019 at 1:59
  • 2
    BTW, you might consider Unix & Linux or SuperUser for questions that are more about command-line UNIX tooling than software development as such. Questions specific to git are certainly on-topic here, but grep isn't meaningfully "unique to software development". Mar 18, 2019 at 2:00

2 Answers 2

2

select only those files whose names contain "q1". However the step the step does not give any result.

grep finds patterns, and q1 is a perfectly fine pattern on its own.

git show commit:.data/path/to/file/ | grep q1
2
  • 1
    Just using q1 gives the answer. I should have mentioned it in my question. However I specifically wanted to use wildcards here. Anyway I have accepted your answer though.
    – itthrill
    Mar 18, 2019 at 2:46
  • The point is that you don't use wildcards in grep like you do when specifying filenames in the shell. If you're just searching for the string "q1" appearing somewhere on the line, then that's all you need to put for your pattern. Mar 18, 2019 at 19:13
0

That command seems wrong, try this:

git show commit:.data/path/to/file | grep "q1"
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.