sedコマンドの助けが必要です

sedコマンドの助けが必要です

sed2000年から2009年の間にリリースされた次のゲームを検索するには、単一のコマンドを入力するのに役立ちます。 (/) 検索しようとしましたが動作しません。

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.06

ベストアンサー1

使用する方が良いアッこのユースケースをテキスト処理ツールとして使用している間は、上記の方法を使用して目的のアイテムを検索できます(この方法はリストでのみ機能します)。

sed  -n '/200[0-9]/p' file

-n : ファイル全体の出力を抑制します。

pコマンド:一致するパターンを印刷するために使用されます。

そしてAWK(列がタブで区切られていると仮定):

awk -F '\t' '{if($4 >= 2000 && $4 <= 2009 ) {print $0}}' file  

おすすめ記事