DEV Community

Discussion on: Two Bash scripts I cannot live without when working with Git

Collapse
 
erykpiast profile image
Eryk Napierała

It turned out that echo -n trick isn't correct neither. I've decided to add the second condition for empty string, so the final version is:

TO_REMOVE=`git clean -f -d -n`;
if [[ "$TO_REMOVE" != "" ]] && [[ `echo $TO_REMOVE | wc -l | bc` != "0" ]]; then
Thread Thread
 
jsn1nj4 profile image
Elliot Derhay • Edited

What about wc -l "$TO_REMOVE"?

Thread Thread
 
erykpiast profile image
Eryk Napierała

I don't think it gonna work. It tries to read a file under the path saved in $TO_REMOVE variable. That's not what we want to do.

Thread Thread
 
jsn1nj4 profile image
Elliot Derhay

Oh interesting. Never mind then. Thanks for helping me understand all of this.