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*"
```
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

```