2

I'm using gnuplot from a bash script and I have to divide values from two columns:

plot "results.csv" using 1:($4/$6) notitle with lp

This works fine in gnuplot interactive mode, but when called from a script, the column values get mixed up with bash script arguments...How can I pass the col. values from the script?

1
  • How do you call gnuplot from your script? Commented Nov 14, 2010 at 20:49

1 Answer 1

3

This depends on how exactly you're invoking gnuplot from your script, as Sean asked in the comments.

Something like $4 will be expanded unless it's in single quotes, so that's one option. Anywhere else, you'll have to escape the $:

# print first argument
echo $1

# print literally $1, a few ways
echo '$1'
echo "\$1"
echo \$1
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Jefromi, escaping with \ worked! Escaping with "$1" produces some strange values. You really helped me a lot with your quick answer :)
@ana: That was a typo in the example. In the text I said only single quotes will protect it from parameter expansion; double quotes do not, so you must escape it with a backslash there too.

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.