1

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.

3
  • 1
    Did you try var=$(head....) ? Commented May 11, 2012 at 7:32
  • Yup.. heres what I get for bacticks , eval and $() line 20: =: command not found. Commented May 11, 2012 at 7:33
  • No need for the head/tail portion of the pipe. Just do: sed -n "${errno}s/,//p" Commented May 11, 2012 at 10:57

1 Answer 1

2

You can do:

var=$(head -"$errno" tmptmptmp2 | tail -1 | sed 's/,//')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.