I have a bash script:

#!/bin/bash

gawk -f realmap.awk realmap.log | column -ts: > realmap.csv

gnuplot <<-_EOF_
    set term png
    set out 'realmap.png'
    set xlabel 'index'
    set ylabel 'bytes'
    set style data lp
    plot 'realmap.csv' u 1:2 t col, '' u 1:3 t col, '' u 1:4 t col, '' u 1:5 t col, '' u 1:6 t col, '' u 1:7 t col
_EOF_

rm realmap.csv

display realmap.png

And a awk script:

#!/usr/bin/gawk -f

BEGIN{
    printf("%s:%s:%s:%s:%s:%s:%s\n", "index", "total", "used", "free", "cached", "buffers", "cache")
}

/^#/{
    gsub("#", "")
    printf("%d:", $0+1)
}

/^M/{
    printf("%d:%d:%d:%d:", $2,$3,$4,$7)
}

/^-/{
    printf("%d:%d\n", $3, $4)
}

How to combine these two scripts as one?

link|improve this question

what do u mean by combine??? Combination depends on what functionality u want to achieve... – Vineet Menon Dec 7 '11 at 5:30
feedback

1 Answer

up vote 0 down vote accepted

You don't need a "here document". Just place the entire awk program — properly quoted so that all of the quotation marks and metacharacters within it are not recognized by the shell and so that the linefeeds and other whitespace don't cause it to be split into multiple arguments by the shell — as the first command-line argument, without using awk's -f option. Without -f, the first command line argument is the program to run. The awk manual page is your friend.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.