Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find a minimum value in a single column and save it at the other file

Status
Not open for further replies.

swlee49

Programmer
Mar 1, 2012
2
US
Hi, I have a simple question. I tried to find an answer here. I found some more complicated things, but I would like to know just this simple one. my find_minimum.dat file has a single column with both positive and negative number such as

1
-2
3
-5.5
2
67
3.8

I would like to find the minimum value, -5.5 and save it into other file, for example, minimum.dat.

Could you let me know how to do this?

Thanks,
SWL
 
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Don't use "awk". Use "sort"

sort -n find_minimum.dat

"sort" to sort.
"-n" for numeric sorting.

That's all!
 
And perhaps head -1 to pull out the single value you require.

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
I deeply appreciate your suggestions. All works!! Now, my data managing becomes 50 times faster than before. I know this is too simple to ask this place, but I did not know how to do at all. Thank you so much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top