简体   繁体   English

命令行排序文件内容并将输出重定向到文件

[英]Command line sorting file content and redirecting output to the file

The file 'numbers' contains a list of numbers.文件“numbers”包含一个数字列表。 Write a command to place the largest one of those numbers into the file 'largest' (there should be nothing else in that file).编写一个命令将这些数字中最大的一个放入文件 'largest'(该文件中应该没有其他内容)。 Do not use the 'head' command in your answer.不要在答案中使用“head”命令。

I am trying sort numbers |我正在尝试对数字进行排序 | tail > largest尾巴 > 最大

你这样写:

sort -n numbers | tail > largest

sort -n numbers | sort -n 数字 | tail -1 > largest尾 -1 > 最大

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM