From d057eeb5a0d792679315118b881f58ac4727e28c Mon Sep 17 00:00:00 2001 From: Benson Muite Date: Thu, 14 Mar 2024 12:57:38 +0300 Subject: [PATCH] Explain how to do arithmetic (#345) * Explain how to do arithmetic * Update episodes/04-redirection.md --------- Co-authored-by: Paul Smith --- episodes/04-redirection.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/episodes/04-redirection.md b/episodes/04-redirection.md index de710a20..6814cc2c 100644 --- a/episodes/04-redirection.md +++ b/episodes/04-redirection.md @@ -236,6 +236,23 @@ $ wc -l SRR098026.fastq Now you can divide this number by four to get the number of sequences in your fastq file. +This can be done using [shell integer arithmetic](https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html) + +```bash +$ echo $((996/4)) +``` + +Note, this will do integer division - if you need floating point arithmetic you can use [bc - an arbitrary precision calculator](https://www.gnu.org/software/bc/manual/html_mono/bc.html) + + +```bash +$ echo "996/4" | bc +``` + +```output +249 +``` + ::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::::::::::