Reputation: 2346
if I do :
echo From ssh://[email protected] | grep -oh From.* | grep -oh ssh.*git
I get what is excepted, which is:
ssh://[email protected]
but if I do:
git ls-remote | grep -oh From.* | grep -oh ssh.*git
I get the following output:
From ssh://[email protected]
Upvotes: 3
Views: 577
Reputation: 242133
The "from" line goes to stderr, so it's ignored by grep. Redirect stderr to stdout to pipe it to grep:
git ls-remote 2>&1 | grep -o 'From.*' | grep -o 'ssh.*git'
Minor changes: -h
is not needed when grepping stdin. Patterns quoted to prevent wildcard expansion by the shell.
Upvotes: 4