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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:34:02+00:00 2026-06-01T00:34:02+00:00

Imagine that you are preparing for an in-depth technical interview and you are asked

  • 0

Imagine that you are preparing for an in-depth technical interview and you are asked to rate your expertise in shell scripting (hypothetically on a scale of one to ten). Then look at the following shell command line example and answer the questions: What does this do? and Why?

unset foo; echo bar | read foo; echo "$foo"

What level of expertise would you map to correctly answer this question for the general case (not merely for one or another, specific, version of the shell)?

Now imagine that you’re given the following example:

cat "$SOMELIST_OF_HOSTS" | while read host; do ssh $host "$some_cmd"; done

… and the interviewer explains that this command “doesn’t work” and that it seems to only execute the ssh command on a few of the hosts listed in the (large) file (something like on in every few hundred hostnames, seemingly scattered from among the list). Naturally he or she asks: Why is it doing that? and How might you fix it?

Then rate the level of expertise to which you would map someone who can answer those questions correctly.

  • 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-01T00:34:04+00:00Added an answer on June 1, 2026 at 12:34 am

    Note that the first example is dependent on the shell. The pipe is an IPC (inter-process communications) operator and the shell can implement that by creating a subshell on either side of the pipe. (Technically I suppose some shell could even evaluate both sides in separate sub-processes).

    The read command is a built-in (must, inherently be so). So, in shells such as bash and the classic Bourne shell derivatives the suprocess (subshell) is on the right of the pipe (reading from the current shell) and that process ends after its read (at the semicolon in this example). Korn shell (at least as far back as ’93) and zsh put their subshell on the other side of the pipe and are reading data from those into the current process.

    That’s the point of the interview question.

    The point of my question here is to look for some consensus or metric for how highly to rate this level of question. It’s not a matter of trivia because it does affect real world scripts and portability for shell scripting and it relies upon fundamental understanding of the underlying UNIX and shell semantics (IPC, pipes, and subprocesses/subshells).

    The second example is similar but more subtle. I will point out that the following change “works” (the ssh will execute on each of the hosts in the file):

    cat $SOME_FILE | while read host; do ssh "$host" "$some_cmd" < /dev/null; done
    

    Here the issue is that the ssh command buffers up input even if the command on the remote never reads from its stdin. Because the shell/subshell (reading from the pipe) and the ssh are sharing the same input stream, the ssh is “stealing” most of the input from the pipeline, leaving only the occasional line for the read command.

    This is not an artificial question. I actually encountered it in my work and had to figure it out. I know from experience that understanding this second example is at least a notch or two above the first. I also know, also from years of experience, that fewer than 10% of the candidates (for sysadmin and programming positions) that I’ve interviewed can get the first question right away).

    I’ve never used the second question in a live interview and I’ve been discouraged from doing so.

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

Sidebar

Related Questions

Imagine that in one data template, I have a textBox, and another data template,
Imagine that you have a Person entity with a one to one relationship with
I asked the question this way because I can imagine that there's a potentially
Imagine that you've got one of these guys: (source: codesampler.com ) Aka GL_TRIANGLE_STRIP. If
Imagine that users can have one or more roles in the system. after login
Imagine that users are inserting strings in several computers. On one computer, the pattern
Imagine that I have 100 SELECT queries that differ by one input. A PreparedStatement
Imagine that you have a simple site with only 2 pages: login.aspx and secret.aspx.
Imagine that you want to develop a non-trivial end-user desktop (not web) application in
Imagine that I will make an async call in .NET, i.e. HttpWebRequest.BeginGetResponse, and the

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.