我需要一个sed命令,它将允许我搜索和显示1980年S发布的所有游戏的信息,并按字母顺序排列这些结果。是否有一种只使用sed就能做到这一点的好方法?
1 Wii Sports Wii 2006 Nintendo 41.36
2 Super Mario Bros. NES 1985 Nintendo 29.08
3 Duck Hunt NES 1985 Nintendo 26.93
4 Tetris GB 1989 Nintendo 23.20
5 Mario Kart Wii Wii 2008 Nintendo 15.91
6 Wii Sports Resort Wii 2009 Nintendo 15.61
7 Kinect Adventures! X360 2010 MS Game Studios 15.09
8 New Super Mario Bros. Wii Wii 2009 Nintendo 14.53
9 Wii Play Wii 2007 Nintendo 13.96
10 Super Mario World SNES 1991 Nintendo 12.78
11 New Super Mario Bros. DS 2006 Nintendo 11.28
12 Pokémon Red/Green/Blue GB 1998 Nintendo 11.27
13 Super Mario Land GB 1989 Nintendo 10.83
14 Call of Duty: Black Ops X360 2010 Activision 9.76
15 Mario Kart DS DS 2005 Nintendo 9.71
16 Super Mario Bros. 3 NES 1990 Nintendo 9.54
17 Grand Theft Auto:San Andreas PS2 2004 Rockstar Games 9.43
18 Call of Duty: Modern Warfare X360 2011 Activision 9.07
19 Grand Theft Auto V X360 2013 Rockstar Games 9.0发布于 2021-11-11 09:37:44
如果您想按名称按字母顺序排序游戏,您可以直接使用sort进行排序。在这里,我选择#作为字段分隔符,因为它不存在于数据集中。
不过,首先,您需要选择上世纪80年代的游戏,因此我使用了grep:
grep -E '^.{39}198.' games | sort -t'#' -k1.5,1.34示例的输出:
3 Duck Hunt NES 1985 Nintendo 26.93
2 Super Mario Bros. NES 1985 Nintendo 29.08
13 Super Mario Land GB 1989 Nintendo 10.83
4 Tetris GB 1989 Nintendo 23.20https://unix.stackexchange.com/questions/676988
复制相似问题