Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 bash,如何获得文件中最长的行?
$ cat file 12 3241234 123 3775 874 62693289429834 8772168376123
我想得到62693289429834。
62693289429834
sort -V file | tail -n1
适用于您的示例输入。我不完全确定它也适用于其他输入,但我认为如此。
awk ' { if ( length > x ) { x = length } }END{ print x }' file