Search code examples
windowsawkgnuplotmsysgitgit-bash

How to run awk in gnuplot scripts via msysgit bash


My gnuplot scripts use awk to preprocess some data. Everything works fine in Linux. But I also like to run these scripts in Windows. Most of the time I use the Git Bash (msysgit) for my command line work in Windows. This saves me from maintaining windows batch files in addition to my shell scripts.

The problem is that Git Bash does not provide a gnuplot command, although it does provide awk. I manually installed Gnuplot (MinGW) and added it's bin dir to the %PATH%.

Now I can run gnuplot from the Git Bash. But since it is a "Windows app" it does not recognize the tools/binaries provided by the MSYS Git, such as awk. I think I could add Git's MSYS bin dir to the %PATH%, but (as the Git installer tells you) this might interfere with some OS systems functions. I also do not want to install another MSYS. The Git version is just fine as it is for me.

Is there a better solution to get gnuplot running with my MSYS binaries (esp. awk).


Solution

  • I found a quite simply solution to my problem. One solution would be adding the full Git/bin to the %PATH% which I did not want to do (see above). But if you just need a few commands you can setup a simple non intrusive "mini" MSYS in one of your bin folders (those already in your %PATH%), or you create a new one and add that to the %PATH%.

    Setting up awk for my gnuplot scripts:

    1. Copy gawk.exe from the Git/bin to %HOME%/bin/awk.exe
    2. Copy msys-1.0.dll from Git/bin to %HOME%/bin
    3. Add %HOME%/bin to your %PATH% (if not already)

    To test it, just open the command line and type awk. I can now double click my plot.sh script which is automatically run via Git's bash. The script calls the gnuplot Windows binary of, which you should also have on your %PATH%, and gnuplot finally (internally) calls awk.

    Works like a charm!