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 8461887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:00:23+00:00 2026-06-10T14:00:23+00:00

I am trying to pipe the output of a tail command into another bash

  • 0

I am trying to pipe the output of a tail command into another bash script to process:

tail -n +1 -f your_log_file | myscript.sh

However, when I run it, the $1 parameter (inside the myscript.sh) never gets reached. What am I missing? How do I pipe the output to be the input parameter of the script?

PS – I want tail to run forever and continue piping each individual line into the script.

Edit
For now the entire contents of myscripts.sh are:

echo $1;
  • 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-10T14:00:24+00:00Added an answer on June 10, 2026 at 2:00 pm

    Generally, here is one way to handle standard input to a script:

    #!/bin/bash
    
    while read line; do
        echo $line
    done
    

    That is a very rough bash equivalent to cat. It does demonstrate a key fact: each command inside the script inherits its standard input from the shell, so you don’t really need to do anything special to get access to the data coming in. read takes its input from the shell, which (in your case) is getting its input from the tail process connected to it via the pipe.

    As another example, consider this script; we’ll call it ‘mygrep.sh’.

    #!/bin/bash
    
    grep "$1"
    

    Now the pipeline

    some-text-producing-command | ./mygrep.sh bob
    

    behaves identically to

    some-text-producing-command | grep bob
    

    $1 is set if you call your script like this:

    ./myscript.sh foo
    

    Then $1 has the value “foo”.

    The positional parameters and standard input are separate; you could do this

    tail -n +1 -f your_log_file | myscript.sh foo
    

    Now standard input is still coming from the tail process, and $1 is still set to ‘foo’.

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

Sidebar

Related Questions

I'm trying pipe the output of an awk command through more than one command
I have been trying to log a script output with syslog-ng , however, if
I'm trying to run a shell command from within a python script which needs
Trying to pipe the output of a sed replacement on a text file into
I'm trying to redirect a patch command output using a named pipe. I tried
I am trying to execute a command in a shell and pipe the output
I am trying to get a cronjob to pipe output into a dated file
I'm trying to run the folowing command on a sub process and collecting the
I'm trying to pipe the output of the parts-of-speech function into the index-words function
I am trying to setup a pipe between one process that is launched with

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.