Laz
Laz

Reputation: 6204

Copy output string to variable after multiple pipes

Im trying to store the output of a set of commands to a variable in a shell script. The obvious backticks and eval are failing. Could someone help me out with this.

I want to store the output of

head -"$errno" tmptmptmp2 | tail -1 | sed 's/,//'

into a variable.

The command works fine BTW.

Upvotes: 1

Views: 125

Answers (1)

codaddict
codaddict

Reputation: 455000

You can do:

var=$(head -"$errno" tmptmptmp2 | tail -1 | sed 's/,//')

Upvotes: 2

Related Questions