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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:40:37+00:00 2026-06-10T08:40:37+00:00

could somebody explain the difference between these two codes? bad_command 2>& >> file.out and

  • 0

could somebody explain the difference between these two codes?

bad_command 2>&  >> file.out 

and

bad_command >> file.out 2>& 

The manual said that these two codes are different,and first command will
output nothing to file.out.

So , here are my questions.

1/ what is the reason for that?

2/ Is there is a document which describes how operator precedence works in shell?
how shell parses and made it’s syntax tree.

3/ What is the correct syntax and order of it?

–Thanks in advance–

  • 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-10T08:40:39+00:00Added an answer on June 10, 2026 at 8:40 am

    Both are syntactically wrong. I assume you meant

    bad_command 2>&1  >> file.out
    

    and

    bad_command >> file.out 2>&1
    

    instead.

    Between these, there is a difference. Redirections are imperative statements, which are worked through from left to right. A redirection operates on a process’ file descriptors (fds). You might have heard of the standard filedescriptors #0 (standard in/stdin), #1 (standard out/stdout), #2 (standard error/stderr).

    The first commandline’s redirections read: “Make fd 2 a copy of fd 1, but then change fd 1 to append to ‘file.out'” (the second redirection has no effect to fd 2, which still is a copy of what fd 1 was at the beginning)

    The seconds ones read: “Change fd 1 to append to ‘file.out’, and then make fd 2 a copy of fd 1” (the first redirection has effect to the second redirection, bot fds are now the same)

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

Sidebar

Related Questions

Could somebody explain me the difference between a .diff file and .patch file.
Could somebody please explain or link to a resource that will tell me why
Could somebody tell me the difference between: int *p; p=(int*)malloc(10*sizeof(int)); free(p); or int *p;
Can somebody explain to me the difference between the project target and the minimum
Could somebody explain what I'm doing wrong in attempting to insert a new UITableViewCell?
Could somebody explain what is the meaning of DomHelper in google closure? What is
Could somebody explain to me the architecture behind chatroulette? I was thinking about a
Could somebody explain me how to map a one-to-zero association with hibernate (using mapping
Could somebody please explain what this notation is in javascript? What is function(d) doing?
Could somebody explain how you can manually create a remember me cookie in a

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.