I have a file as below. It contains two data sets separated by >.
I want to pipe each data set to another program called psxy. How
can I get the different records
Have started doing as follows but it only passes the first data set
kristinu, does psxy accept - as a filename indicating that it should read from standard input?
If it does, you can execute psxy inside an awk script feeding it the portions of your input file between the ( > ) separator line without creating intermediate files.
kristinu,
Sorry for the delay in responding. Hopefully, alister's comments were enough to explain what I was suggesting. If not, the following should work. My script is a little more complex than your original script because the awk I'm using doesn't allow multiple characters in RS. So, you can simplify it on your system, but the following is more portable to other systems.
If you wanted to run this on a Solaris/SunOS system, you'd need to use /usr/xpg4/bin/awk or nawk instead of awk .
Note that this script produces files p001.ps , p002.ps , etc. If you have less than 100 sections or more than 1000 sections in p.dat , you could change the %03d in the sprintf() format string to specify a different number of digits in the output file names.
I have not tested it, but it looks like that code will send a ">" into the pipe if the first "dataset" is empty. Also, if a "dataset" is empty, should psxy be invoked and immediately read EOF? If so, then the above is incorrect in that respect as well.
The problem statement was insufficiently precise to make those determinations, so neither case may be of concern. Just an observation.
Thanks Alister,
I considered both of these issues, but the idea of graphing zero points didn't make any sense to me. So, I didn't worry about those cases. However, I should have stated my assumptions when I posted my proposal.