I tried your script, there is no issue, but if I set alias ls='ls --color=always'
, I will have the same issue
maybe your ls
returns some hidden characters like color code
can you try
for f in `\ls *.txt.gz`
but you could have used
for f in *.txt.gz
instead of
for f in `ls *.txt.gz`
and if your system has zgrep
, you could use zgrep MYBOND $f
instead of zcat $f | grep MYBOND
The code will be like this:
for f in *.txt.gz; do echo "$f"; zgrep MYBOND "$f"; done