DEV Community

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

Collapse
erykpiast profile image
Eryk Napierała Author

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
JSn1nj4‍‍👨‍💻 • Edited on

What about wc -l "$TO_REMOVE"?

Thread Thread
erykpiast profile image
Eryk Napierała Author

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
JSn1nj4‍‍👨‍💻

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