Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9157883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:07:30+00:00 2026-06-17T13:07:30+00:00

The following code: #!/bin/bash -x mkfifo pipe 2>/dev/null tee pipe >/dev/null & cat pipe

  • 0

The following code:

#!/bin/bash -x
mkfifo pipe 2>/dev/null
tee pipe >/dev/null &
cat pipe

produces no output when run as follows:

$ echo "hi" | ./test.sh
+ mkfifo pipe
+ cat pipe
+ tee pipe
$

Why?! I would expect tee to copy stdin to the named pipe (and /dev/null), and then cat to copy the contents of the named pipe to stdout. Why doesn’t it work?!

I’m trying to write a bigger bash script and I really need the tee in there, with something else in the place of /dev/null. I narrowed down the unexpected behaviour to the example above.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:07:31+00:00Added an answer on June 17, 2026 at 1:07 pm

    when you background a process its standard input will be set to /dev/null

    #!/bin/bash -x
    mkfifo pipe 2>/dev/null
    cat - | tee pipe >/dev/null &
    cat pipe
    

    So you need to specify you want the stdin of the parent, in your case the pipe between echo and ./test.sh

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not getting the result expect from the following code: #!/bin/bash cat /home/opmeitle/html/fiesta-one.html |
W/hen i run the following code snippet #!/bin/bash if [ foo = foo ];
I am getting this error when I run the following code: #!/usr/bin/env ruby -rubygems
Suppose I have the following code in bash: #!/bin/bash bad_fruit=( apple banana kiwi )
I have the following code: #!/bin/bash for f in `find . ! -type d`;
Running the following code: #!/bin/bash set -o pipefail set -o errtrace set -o nounset
The following code works fine #!/bin/bash while true; do echo $(pwd | awk '{print
I'm trying to convert the following bash code into C++ using boost::iostreams: #!/usr/bin/bash (
Consider the following code snippet: #!/bin/bash #This program tests the if statement in bash.
I am using the following code to launch a command on another machine: #!/bin/bash

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.