How to run a bash script in Rust

Drashti Shah
Bioinformatics with Rust
1 min readDec 18, 2023


Generated with AI

Bash scripting is a useful skill for computational biologists. Since writing all algorithms from scratch in Rust is not our goal, there are command-line tools like TopHat and Bowtie that make our lives easier. This article explains how you can run a bash script inside a Rust project.

The following script downloads a mouse gene data package from NCBI. You can find the instructions to install the datasets command-line tool here.

Step 1

Create a new file called and paste the commands below.


# Install the datasets command-line tool from NCBI before running this
datasets download gene accession NM_001252684.2

Step 2

Make the file executable.

chmod +x

Step 3

Run the bash script inside your Rust workflow.

use std::process::Command;

// Create a new command that runs bash
let mut command = Command::new("bash");

// Pass the script name as an argument

// Execute the command
// This will download a file called in the current directory
command.output().expect("Failed to execute command");

Next Steps



Drashti Shah
Bioinformatics with Rust

ESG & climate data scientist by day. Aspiring computational biologist by night.