Print smallest integer from file using awk custom function?
`awk` function looks like this in a file name `fun.awk`:
Quote:
Quote:
awk -f fun.awk awk.write It gives me no result? Why? |
Use a simpler program, e.g.
Code:
NR==1 || $1 < minimum { minimum = $1 } |
Quote:
|
It would be rather different, clumsy and un-awk-ish. Why do you insist on a function?
And what is that function's specification - input and output? Let me elaborate why I think a function is the wrong solution. awk programs consist of pattern-action pairs which work on one line at a time. Users can define functions for better structuring their actions. Your task requires processing the entire file. While that is possible inside a single awk action, for instance using the built-in function getline, it's against awk's nature. It will also be hard to read compared to my two-line program. |
All times are GMT -5. The time now is 03:26 AM. |