Sample Header Ad - 728x90

Reading multiple lines in Bourne Shell

1 vote
3 answers
1751 views
I'm trying to read two lines into two variables. In Bash I would use something like this: cat myfile line1 line2 EOF cat myfile | { read firstline echo $firstline # "line1" in bash and sh read secondline } echo $firstline # "line1" in bash, empty in sh echo $secondline In Bourne Shell however $firstline and $secondline are empty outside the command group. How can I do it in sh?
Asked by jasper (121 rep)
May 11, 2020, 06:22 PM
Last activity: May 11, 2020, 10:40 PM