I am trying to add a condition in this code, that if there is null string in translation file for either string or repl[string] for example, my file input_chk.txt has following details:
input_chk.txt
b73_chr10 w22_chr2
w22_chr7 w22_chr10
w22_chr8
Code :
#!/usr/bin/awk -f
# Collect the translations from the first file.
NR==FNR { repl[$1]=$2; next }
# Step through the input file, replacing as required.
{
if
for ( string in repl ) {
if (length(string)==0)
{
echo "error"
}
else
{
sub(string, repl[string])
}
}
#if string is null-character,then we have to add rules,
#if repl[string] is null-character,then we have to delete rules or put # in front of all lines until we reach </rules> also
# And print.
1
# to run this script as $ ./bash_script.sh input_chk.txt file.conf
file.conf
<rules>
<rule>
condition =between(b73_chr10,w22_chr1)
color = ylgn-9-seq-7
flow=continue
z=9
</rule>
<rule>
condition =between(w22_chr7,w22_chr2)
color = blue
flow=continue
z=10
</rule>
<rule>
condition =between(w22_chr8,w22_chr3)
color = vvdblue
flow=continue
z=11
</rule>
</rules>
But,my code is showing error in line 8.How to include the condition so that it can print error if there is a string missing either in first column or second column.
if (string in repl)
instead ofif for (string in repl)
will fix the error.