Question: I must develop some shell scripts that call some repetitive code that execute sql commands to database.
What is the best method to make these, with functions in an external shell script, with external shell script with these sql commands or why?

Answer: 
***awk*** solution:

```
awk -F':' -v RS="@" 'NR>1 && ($5<1101 || $5>1103){ print RS$0 }' myfile.fq

```

The output:

```
@ST-E00204:114:HHKTJALXX:4:1104:7101:2012 2:N:0:1
NATTTAAAAATACCCACTATAAAACATAAAATATAACAAAAAAACTAAAAATCATAAAAAATAAAAAAAATCCACTTCACGTCTTTTAACAATTTCGTCATTTTTAACATCCTCAAATAAATTATTCTCATTTTCCATAACTTCCAATTTT
+
!A-A-FJJJJJJ-FJAJFJJJJJFJJAJJJJJJ-F-AJJJJJJ-F-FJJFJJFJFFFFF<-F

```

---

*Details*:

* `-F':'` - field separator `:`
* `-v RS="@"` - considering `@` as record separator
* `($5<1101 || $5>1103)` - check if the needed field fits the condition "*remove between 1101 to 1103*"
Here's an awk solution that assumes that every block is exactly 4 lines long.

```
awk -F ':' '
    NR % 4 == 1 { keep = ($5 < 1101 || $5 > 1103) }
    keep
'

```

Explanations:

* `-F :` sets the field separator to `:`. `$5` is the fifth field on the current line (numbered from 1).
* `NR % 4 == 1 { … }` executes the code in the braces if the condition `NR % 4 == 1` is true, i.e. if the current line number is a multiple of 4 plus 1.
* `keep = (…)` sets the variable `keep` to the specified condition.
* The line with just `keep` says to print the current line if the variable `keep` is true. Since `keep` is only set every 4 lines, it applies identically to all the lines within a 4-line block.