Skip to content

Commit 546cfbe

Browse files
authored
Update 04-redirection.md
Updated `grep` section to reflect outputs as of March 2026. The data available from https://figshare.com/articles/dataset/Data_Carpentry_Genomics_beta_2_0/7726454?file=14417834 for this lesson does not produce the same number of read matches for each `wc` command. Additionally, the `tail` command with `SRR098026.fastq` does not produce the same output due to the file. The numbers and outputs have been changed to reflect the current data. Additionally, added short instructions in between the commands writing and appending to files since just the commands and outputs do not make it clear what is happening.
1 parent 9337b0f commit 546cfbe

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

episodes/04-redirection.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,14 @@ We can check the number of lines in our new file using a command called `wc`.
208208
in a file. The FASTQ file may change over time, so given the potential for updates,
209209
make sure your file matches your instructor's output.
210210

211-
As of Sept. 2020, wc gives the following output:
211+
As of March. 2026, wc gives the following output:
212212

213213
```bash
214214
$ wc bad_reads.txt
215215
```
216216

217217
```output
218-
802 1338 24012 bad_reads.txt
218+
537 1073 23217 bad_reads.txt
219219
```
220220

221221
This will tell us the number of lines, words and characters in the file. If we
@@ -226,7 +226,7 @@ $ wc -l bad_reads.txt
226226
```
227227

228228
```output
229-
802 bad_reads.txt
229+
537 bad_reads.txt
230230
```
231231

232232
::::::::::::::::::::::::::::::::::::::: challenge
@@ -305,7 +305,7 @@ $ wc -l bad_reads.txt
305305
```
306306

307307
```output
308-
802 bad_reads.txt
308+
537 bad_reads.txt
309309
```
310310

311311
```bash
@@ -324,35 +324,39 @@ search sequence. So our file was overwritten and is now empty.
324324
We can avoid overwriting our files by using the command `>>`. `>>` is known as the "append redirect" and will
325325
append new output to the end of a file, rather than overwriting it.
326326

327+
First, run the `grep` command for the (`SRR098026.fastq`) file.
328+
327329
```bash
328330
$ grep -B1 -A2 NNNNNNNNNN SRR098026.fastq > bad_reads.txt
329331
$ wc -l bad_reads.txt
330332
```
331333

332334
```output
333-
802 bad_reads.txt
335+
537 bad_reads.txt
334336
```
335337

338+
Then, run the `grep` command for the (`SRR097977.fastq`) file, appending the output of this command to (`bad_reads.txt`)
339+
336340
```bash
337341
$ grep -B1 -A2 NNNNNNNNNN SRR097977.fastq >> bad_reads.txt
338342
$ wc -l bad_reads.txt
339343
```
340344

341345
```output
342-
802 bad_reads.txt
346+
537 bad_reads.txt
343347
```
344348

345349
The output of our second call to `wc` shows that we have not overwritten our original data.
346350

347-
We can also do this with a single line of code by using a wildcard:
351+
We can also do this with a single line of code by using a wildcard to match both `fastq` files in our directory:
348352

349353
```bash
350354
$ grep -B1 -A2 NNNNNNNNNN *.fastq > bad_reads.txt
351355
$ wc -l bad_reads.txt
352356
```
353357

354358
```output
355-
802 bad_reads.txt
359+
537 bad_reads.txt
356360
```
357361

358362
::::::::::::::::::::::::::::::::::::::::: callout
@@ -423,19 +427,19 @@ $ tail bad_reads.txt
423427
```
424428

425429
```output
430+
#!!!!!!!!!##########!!!!!!!!!!##!#!
426431
@SRR098026.133 HWUSI-EAS1599_1:2:1:0:1978 length=35
427432
ANNNNNNNNNTTCAGCGACTNNNNNNNNNNGTNGN
428433
+SRR098026.133 HWUSI-EAS1599_1:2:1:0:1978 length=35
429434
#!!!!!!!!!##########!!!!!!!!!!##!#!
430435
--
431-
--
432436
@SRR098026.177 HWUSI-EAS1599_1:2:1:1:2025 length=35
433437
CNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
434438
+SRR098026.177 HWUSI-EAS1599_1:2:1:1:2025 length=35
435439
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
436440
```
437441

438-
The fifth and six lines in the output display "--" which is the default action for `grep` to separate groups of
442+
The sixth line in the output displays "--" which is the default action for `grep` to separate groups of
439443
lines matching the pattern, and indicate groups of lines which did not match the pattern so are not displayed.
440444
To fix this issue, we can redirect the output of grep to a second instance of `grep` as follows.
441445

0 commit comments

Comments
 (0)