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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:16:20+00:00 2026-05-28T20:16:20+00:00

Is there a way to append the stdout output of one command to another’s

  • 0

Is there a way to append the stdout output of one command to another’s and pipe the combined output to another command? I used to use the following approach(taking ack-grep as an example)

# List all python, js files in different directories
ack-grep -f --py apps/ > temp
ack-grep -f --js -f media/js >> temp
cat temp | xargs somecommand

Is there a way to do this in a single command?

  • 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-05-28T20:16:21+00:00Added an answer on May 28, 2026 at 8:16 pm

    Just run the two ack-grep commands as a compound command; then pipe the results of the compund command. The first compound command defined in man bash is the parentheses:

       (list) list is executed in a subshell environment (see  COMMAND  EXECU-
                  TION  ENVIRONMENT below).  Variable assignments and builtin com-
                  mands that affect the  shell's  environment  do  not  remain  in
                  effect  after  the  command completes.  The return status is the
                  exit status of list.
    

    So:

    james@bodacious-wired:tmp$echo one > one.txt
    james@bodacious-wired:tmp$echo two > two.txt
    james@bodacious-wired:tmp$(cat one.txt; cat two.txt) | xargs echo
    one two
    

    You can use curly braces to similar effect, but curly braces have a few syntactical differences (they’re more finicky about needing spaces between the brace and other words, for instance). The biggest difference is that the commands inside braces are run in the current shell environment, so they can impact on your environment. For instance:

    james@bodacious-wired:tmp$HELLO=world; (HELLO=MyFriend); echo $HELLO
    world
    james@bodacious-wired:tmp$HELLO=world; { HELLO=MyFriend; }; echo $HELLO
    MyFriend
    

    If you want to get really fancy you can define a function and execute that:

    james@bodacious-wired:tmp$myfunc () (
    > cat one.txt
    > cat two.txt
    > )
    james@bodacious-wired:tmp$myfunc | xargs echo
    one two
    james@bodacious-wired:tmp$
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a following dictionary: d = {'key':{'key2':[]}} Is there any way to append
Is there a way to append a cookie into an already made and used
in F#, array.append can join two arrays; is there a way to append 2
Is there a best (see below) way to append two byte arrays in C#?
Is there a way to append something to the query string with no value
Is there any way I can append a div to the slider handle, so
Is there a way to get sqlite to output additional SQL to drop database
When doing something like $output = shell_exec(command 2>&1); collecting the command's stdout & stderr
Is there a way to append an anchor (test.aspx#23432) in the codebehind to the
Is there a way to append 2 void* ptr? Each is an array of

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.