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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:25:33+00:00 2026-05-12T15:25:33+00:00

ls > ls.out this will include ls.out in the list too. My understanding is:

  • 0
ls > ls.out

this will include ls.out in the list too.
My understanding is: > (shell output redirection operator is creating a file first (to take the STDOUT) if it is not already existing and then ls command is coming to play and it is including the just created ls.out file in the output.
Is this correct? If not, can you please elaborate the workings of that command.

Similarly

wc temp > temp

Will print 0 0 0 temp inside the just created temp file.

This behavior of shell is interesting. I wonder, how it is actually working. BTW, both are exercises in The Unix Programming Environment Book. As I mentioned the answer above, I want some expert to correct my understanding.

  • 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-12T15:25:34+00:00Added an answer on May 12, 2026 at 3:25 pm

    When redirecting standard output with >, the shell will create the file (as an empty file) if it doesn’t already exist. Further, that file is opened before the shell forks and execs the command being executed. When you do wc temp > temp, the shell opens the file for writing and then forks and execs wc, passing on its open file handles in the process.

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

Sidebar

Related Questions

So this question will get technical – eventually – but first check out Hanselminutes
First check out this code. I seems like it should work for me, but
Check out this test: [TestFixture] public class Quick_test { [Test] public void Test() {
In trying to figure out this problem (which is still unsolved and I still
Update: Check out this follow-up question: Gem Update on Windows - is it broken?
It turns out this whole misunderstanding of the open() versus fopen() stems from a
How can i find out this information? Ie, I can install boost 1.35 with
I've tried figuring out this problem for the last 2 days with no luck.
I am currently trying out this code: NSString *path = [[NSBundle mainBundle] pathForResource:@dream ofType:@m4a];
I am trying to figure out this: c = 1 def f(n): print c

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.