Quote:
Originally Posted by
pravani1
But the value of numbers are not fixed. But i want to grep only last min to max nos.... please help
What does grep have to do with this?
And what do you mean by min to max with relation to 'last 3'?
Here's a simple was to get the sorted last 3:
sort -un filename | tail -3
Here's a simple was to get the min and max:
sort -un filename | head -1 ; sort -un filename | tail -1
FYI: The u switch produces unique output, while the n switch sorts numerically (i.e. so 234 comes before 1234).
---
Intersting:
For curiosity, I changed one of the 432 values in the middle to 0432 then tried it and got this result:
sort -un filename
315
381
382
0432
433
I had to use sort WITHOUT the u switch followed by uniq to include both 0432 and 432:
sort -n filename | uniq
315
381
382
0432
432
433