1

I'm trying to search for file that match a given pattern using grep.

This works fine when typed directly into the terminal, returns all files with "zips" in the path.

svn st -u ~/includes ~/scripts ~/htdocs/intra ~/htdocs/update ~/htdocs/sponsor ~/survey ~/htdocs/coupon | grep "zips"

I want to add this functionality to a bash script so I can just call check zips

This is what I've got, but it's ignoring everything after the pipe and returning all output of the first command.

#!/bin/bash
QU=$1
svn st -u ~/includes ~/scripts ~/htdocs/intra ~/htdocs/update
~/htdocs/sponsor ~/survey ~/htdocs/coupon | grep "$QU"

How can I get this bash script to honor the grep call?

5
  • when i run the bash script as shown above, it returns the full output of svn st -u ~/includes ~/scripts ~/htdocs/intra ~/htdocs/update ~/htdocs/sponsor ~/survey ~/htdocs/coupon and ignores the ` | grep "$QU"` Commented Oct 1, 2015 at 18:52
  • 3
    Make sure the whole pipe is really all on one line in the file; if there's a newline in there you'd have to remove or escape it. Commented Oct 1, 2015 at 18:53
  • @TextGeek that was the problem. Nano was adding linebreaks i didn't notice. Commented Oct 1, 2015 at 19:06
  • Dang, I should have made that an answer instead of a comment, so the upvotes would count... :) Glad it worked for you! Commented Oct 1, 2015 at 19:09
  • 1
    @TextGeek, please, by all means go ahead. i don't get my little 2 points unless someone posts an answer for me to accept anyway :p Commented Oct 1, 2015 at 19:13

1 Answer 1

2

Make sure the whole pipe is really all on one line in the file; if there's a newline in there you'd have to remove or escape it.

:)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.