1

I want to grep a Gemfile in few rails apps. But for each rails app there are many branches and out of which the latest branch name lets say is 'main'.

The structure is something like this:

workspace   
  rails-apps    
    rails-app1
      main
      feature-branch    
    rails-app2
     main
     feature-branch
     feature-branch2

So I am doing something like this:

grep -R "rails" /workspace/rails-apps/ --include="Gemfile"

but when I do this it greps all the Gemfiles in all the branches which I dont want. I just need to grep only Gemfile in main branch.

Something like this: grep -R "rails" /workspace/rails-apps/*/main --include="Gemfile" but it doesnt work.

1

Have you tried this?

grep -R "rails" /workspace/rails-apps/*/main/Gemfile
  • even this thing works grep -R "rails" /workspace/rails-apps/*/main --include="Gemfile" the fact was I didnt notice that I was doing grep in wrong path. :( – uday Aug 25 '15 at 19:55
  • what do I do if I want to just the standalone word 'rails' in grep? – uday Aug 25 '15 at 19:56
  • You can try to mark word boundaries wih \b. Replace "rails" by "\brails\b". – Cyrus Aug 25 '15 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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