Cover by Ron Peters

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

CHAPTER 10Piping Input to read

This chapter deals with a gotcha that I came across while porting a script from ksh to bash. It was a gotcha only because at the time I wasn't aware of a fairly crucial difference in the behavior of the two shells. In both pdksh and bash, the last command of a pipeline is performed in a subshell. This means that a variable assigned within the subshell is not available to the parent shell. In ksh, the last command of a pipeline is executed in the original shell.

This isn't an issue when using the pipe to set a variable, but if the result of a pipe is sent to a loop structure that then populates variables you will use later, that is more of a problem. Once the loop completes, the variables you were going to rely ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required