I'm piping some Unix commands with my own scripts. The problem is that in my scripts, I'm using colors. Like for example:
yellow=`tput setaf 3`
reset=`tput sgr0`
function Warning()
{
echo "${yellow}$*${reset}"
}
I have a command that prints the path of some directories, using Warning "Compress $directory"
.
I want to pipe it into the find command.
I'm using:
./compress.sh | grep Push | awk '{print $2}' | while read directory; do find $directory | wc -l; done;
However, I get this error:
find: ‘/some_directory\033(B\033[m’: No such file or directory 0
It seems that either awk
puts some invisible characters to the end of its print, or the color messes up with piping.
Why do I get this error? What should I do?