Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8139911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:59:07+00:00 2026-06-06T11:59:07+00:00

I have a very simple script: #!/bin/bash gnuplot << EOF set term postscript portrait

  • 0

I have a very simple script:

#!/bin/bash
gnuplot << EOF
set term postscript portrait
set output 'out.ps'

plot 'data_file' u 3:($2==0.0 ? $2:1/0)

EOF

where data_file looks like this:

  O4     -1.20     -0.33     -5.20  
O9.5     -1.10     -0.30     -3.60  
  B0     -1.08     -0.30     -3.25  
B0.5     -1.00     -0.28     -2.60  
B1.5     -0.90     -0.25     -2.10  
B2.5     -0.80     -0.22     -1.50  
  B3     -0.69     -0.20     -1.10  
....

I have tried several combinations and I still get the same error always:

gnuplot> plot 'S-K_data' u 3:(==0.0 ? :1/0)
                          ^
         line 0: invalid expression 

As you can see, it’s not reading the $2 characters and I just can’t figure out why.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:59:08+00:00Added an answer on June 6, 2026 at 11:59 am

    In an unquoted here doc, variables are expanded. Try

    gnuplot << 'EOF'
    

    or

    gnuplot << \EOF
    

    Which you choose is a matter of personal preference (you can use any quoting mechanism, so EOF"" works, but the two above are the most common). When the heredoc delimiter is unquoted, the shell is expanding $2 to the second parameter passed to the script. (Try calling the script with 2 arguments.) When the heredoc delimiter is quoted, no such expansion takes place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple test bash script which looks like that: #!/bin/bash cmd=rsync -rv
i have a very simple script that reads out a txt file, puts the
I have written a very simple bash script to help me migrate from dev
I have a very simple script that creates a user: <?php include 'mysqlserver.php'; session_start();
At the moment I have a very simple script. If I type the commands
I have a very simple python script that should scan a text file, which
I have a very simple jQuery script.. all I want it to do is
I have a very simple Powershell v1.0 script to kill processes by name: $target
I have written a very very very simple!! script in php. header redirection not
Let's say I have the following, very simple block of code: <script> function hasVal(field)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.