Remove specific word from data contents problem asking

Hi,
Below is my input file:

>tempZ_1
SAFSDAFDSG
GGERRTTZZZ
ZASRARARET
WETPOASDAZ
ZZZASASFAS

>temp_9
ASAEGPIOEO
EIOPIZZZAS
FDFGZZZARA
ESEAZZZAAS
.
.

Desired output file:

>tempZ_1
SAFSDAFDSG
GGERRTTASR
ARARETWETP
OASDAASASF
AS

>temp_9
ASAEGPIOEO
EIOPIASFDF
GARAESEAAA
S
.
.

My purpose is want to delete all the "Z" from the input file's content.
I got try the following command:

sed 's///g' input_file
>tempZ_1
SAFSDAFDSG
GGERRTT
 ASRARARET
WETPOASDA
   ASASFAS

>temp_9
ASAEGPIOEO
EIOPI   AS
FDFG   ARA
ESEA   AAS
.
.

It still can't archive my desired goal :frowning:
Thanks for any advice.

I take it you want to delete any line that has a "Z" in it?

# sed '/Z/d' inputfile
or 
awk '!/Z/' inputfile

Hi,

Thanks for your suggestion.
I just test your code suggestion.
It seems like it will delete all line that include 'Z' word instead of just delete 'Z' word only?
Thanks.

awk 'END { say(_) }        
NR == 2 { l = length } 
/^>/ { 
  _ && say(_); _ = z 
  print; next 
  }
{ _ = _ ? _ $0 : $0 }
func say(x) {
    gsub(/Z/, z, x) 
    while (match(x, /........../)) {
      print substr(x, RSTART, RLENGTH)
      x = substr(x, RLENGTH + 1)
        }
    if (x) printf "%s\n\n", x
    }' infile 

Okay - now I understand - just delete the word not the line

awk '{for(i=1; i<= NF; i++) 
         { if( match($i, /Z/)
              {next}; 
           printf("%s ", $i)}; print ""}' inputfile >newfile
$ while read line; do
> if ! echo $line | grep -o "^>.*" >/dev/null; then
> echo $line | sed 's/Z//g'
> else
> echo $line
> fi
> done <infile.dat
>tempZ_1
SAFSDAFDSG
GGERRTT
ASRARARET
WETPOASDA
ASASFAS

>temp_9
ASAEGPIOEO
EIOPIAS
FDFGARA
ESEAAAS
$ 

Simply type ">newfile.dat" after "<infile.dat" if you want to redirect the output in a new file instead of only printing it on screen.

Edit: Looks like I missed something :rolleyes:

or

tr -d "Z\n" <infile |fold -w 10

HTH

Or...

awk '/^>/{print "\n"$0;n=0;next}{
 for(i=0;++i<=length($0);){
  c=substr($0,i,1)
    if(c!="Z"){(n==10?n=1:++n)
      printf (n==10?c"\n":c)}
}
 }' infile
# sed -e :jump -e 'N; s/\n//;bjump' tempZ_1 | sed 's/Z//g' | sed -e 's/\(..........\)/\1\n/g'
SAFSDAFDSG
GGERRTTASR
ARARETWETP
OASDAASASF
AS
# sed -e :jumpx -e 'N; s/\n//;bjumpx' temp_9 | sed 's/Z//g' | sed -e 's/\(..........\)/\1\n/g'
ASAEGPIOEO
EIOPIASFDF
GARAESEAAA
S
 awk '{if (/^>/||/^$/) {print $0} 
       else {gsub(/Z/,"",$0);printf $0}}' infile |fold -w 10