更新时间:2023-02-26 18:43:50
如果没有负数,你可以使用这个:
You can use this if no negative number is expected:
awk '$0>x{x=$0};END{print x}' input.txt
用它来支持负数:
awk 'BEGIN{x=-2147483648};$0>x{x=$0};END{print x}' input.txt
初始化 x
允许该解决方案正确处理值
Initializing x
allows the solution to properly handle integer lists with values <= 0. See the comments for more details.