Title: Piping Bash
Author: Immanuel Raj
Published: March 4, 2024
Last modified: February 15, 2025

---

# Piping Bash

[March 4, 2024](https://immanuelraj.dev/piping-bash/)

—

by

[Immanuel Raj](https://immanuelraj.dev/author/iamimmanuelraj/)

in [Linux](https://immanuelraj.dev/category/linux/)

Read Time

1–2 minutes

Bash is good, ZSH is also good….but the fact that they both do not allow piping 
is bad.

Well technically they do work, but it works in a different way.

Sometimes its okay for us, rest times it is not.

So what’s the issue here…

Say you have a code in your bash script like this

    ```wp-block-code
    apt install fail2ban...read -sp "Enter your Name : " namesed -i "/name =/ s/$/$name/" /etc/hostname...
    ```

The above code can work if we save it inside a `script.sh` and also normally when
piping..but it does not work as we expected [Does not wait and get the input from
read instead it goes and skip to the next command regardless of what the previous
command was] 
This is because when you pipe it to bash…it does execute it one by
one and not line by line…when these both can seem similar…it is clearly not.

You can think this like a rude boss who does not show respect but needs tons of 
respect. Say you say good morning when your boss comes in but he just walks away

But when you do the same when saving it in a script its like giving a handshake 
to your boss and then him waiting and shaking back until you both mutually leave
hand.

There are fixes tho. like you can add `read -sp "Enter your Name: " name < /dev/
tty` to link it with a terminal input and it should work as expected as we wanted.
But this works only in TTY.

[bash](https://immanuelraj.dev/tags/bash/) [fail2ban](https://immanuelraj.dev/tags/fail2ban/)
[linux](https://immanuelraj.dev/tags/linux/) [piping](https://immanuelraj.dev/tags/piping/)

[Previous:  Pa11y and Pa11y-CI Accessibility testing](https://immanuelraj.dev/pa11y-and-pa11y-ci-accessibility-testing/)

[Next:  Demystifying MySQL’s UTF8MB4: A Guide to Character Encoding in Databases with WordPress in GCP and Cloud SQL](https://immanuelraj.dev/demystifying-mysqls-utf8mb4-a-guide-to-character-encoding-in-databases-with-wordpress-in-gcp-and-cloud-sql/)

![Immanuel Raj Avatar](https://secure.gravatar.com/avatar/88db6e1fa27cf854075acbaa156189ace30cf3701b2d8640cd774280ead1d4d3?
s=80&d=mm&r=g)

## About the author

Software Developer & Technology Consultant

---

## Popular Categories

 * [Bible](https://immanuelraj.dev/category/bible/) (1)
 * [Cloudflare](https://immanuelraj.dev/category/cloudflare/) (1)
 * [Databases](https://immanuelraj.dev/category/databases/) (1)
 * [Docker](https://immanuelraj.dev/category/docker/) (1)
 * [Email](https://immanuelraj.dev/category/email/) (1)
 * [ERPNext](https://immanuelraj.dev/category/erpnext/) (3)
 * [Frappe](https://immanuelraj.dev/category/frappe/) (2)
 * [Github Actins](https://immanuelraj.dev/category/github-actins/) (1)
 * [God](https://immanuelraj.dev/category/god/) (1)
 * [Google Cloud](https://immanuelraj.dev/category/gcp/) (1)
 * [Hosting](https://immanuelraj.dev/category/hosting/) (2)
 * [Life](https://immanuelraj.dev/category/life/) (1)
 * [Linux](https://immanuelraj.dev/category/linux/) (13)
 * [ML](https://immanuelraj.dev/category/ml/) (1)
 * [Networking](https://immanuelraj.dev/category/networking/) (2)
 * [Security](https://immanuelraj.dev/category/security/) (2)
 * [Self Hosting](https://immanuelraj.dev/category/self-hosting/) (7)
 * [SSL](https://immanuelraj.dev/category/ssl/) (3)
 * [Terminal](https://immanuelraj.dev/category/terminal/) (1)
 * [Tools](https://immanuelraj.dev/category/tools/) (2)
 * [Uncategorized](https://immanuelraj.dev/category/uncategorized/) (8)
 * [Web](https://immanuelraj.dev/category/web/) (2)
 * [WordPress](https://immanuelraj.dev/category/wordpress/) (1)

---

## Useful Links

Links I found useful and wanted to share.

 * [Sponsor Me](https://github.com/sponsors/iamimmanuelraj)

---

## Search the website

Search