I wrestled a bear once.
I wrestled a bear once.

Reputation: 23379

Grepping output of command in a bash script

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?

Upvotes: 1

Views: 251

Answers (1)

TextGeek
TextGeek

Reputation: 1237

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.

:)

Upvotes: 2

Related Questions