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: 
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.
```
sed -e '
   /@/s/:/\n/4; /@/s/:/\n/4
   /\n110[1-3]\n/,/^$/d
   y/\n/:/
' fastq.data

```

---

1. Mark the serial number on lines that begin with `@`.
2. Delete the chunk which holds the serial number 1101 or 1102 or 1103.
3. On all other chunks take away the markers and let it go to stdout.

---

Result
------

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

```