mercredi 3 octobre 2018

Assign grep output to a variable

I have following already to assign the output of grep to a variable

DUPLICATE_TAGS=$(grep -ho '@MCC[0-9]\{6\}_[0-9]\{3\}' -R src/ft/resources/features/ | sort | uniq -c | grep -v '^ *1 ')

However, when the last grep doesn't match anything the script terminates immediately. I expect empty string in such case.

Any ideas?

Aucun commentaire:

Enregistrer un commentaire