練習問題

練習問題

問1 sedを使用してbook.txtの1行以外の行を出力するコマンドを完成してください。

[user01@localhost ~]$ sed ??? books.txt
2) The Two Towers, J. R. R. Tolkien, 352
3) The Alchemist, Paulo Coelho, 197
4) The Fellowship of the Ring, J. R. R. Tolkien, 432
5) The Pilgrimage, Paulo Coelho, 288
6) A Game of Thrones, George R. R. Martin, 864

問2 sedを使用してbook.txtの3~4行以外の行を出力するコマンドを完成してください。

[user01@localhost ~]$ sed ??? books.txt
1) A Storm of Swords, George R. R. Martin, 1216
2) The Two Towers, J. R. R. Tolkien, 352
5) The Pilgrimage, Paulo Coelho, 288
6) A Game of Thrones, George R. R. Martin, 864

問3 sedを使用してbook.txtの3で始まる行以外の行を出力するコマンドを完成してください。

[user01@localhost ~]$ sed ??? books.txt
1) A Storm of Swords, George R. R. Martin, 1216
2) The Two Towers, J. R. R. Tolkien, 352
4) The Fellowship of the Ring, J. R. R. Tolkien, 432
5) The Pilgrimage, Paulo Coelho, 288
6) A Game of Thrones, George R. R. Martin, 864

問4 sedを使用してbook.txt内の文字列「The」のすべてを小文字「the」に変換してください。

[user01@localhost ~]$ sed ??? books.txt
1) A Storm of Swords, George R. R. Martin, 1216
2) the Two Towers, J. R. R. Tolkien, 352
3) the Alchemist, Paulo Coelho, 197
4) the Fellowship of the Ring, J. R. R. Tolkien, 432
5) the Pilgrimage, Paulo Coelho, 288
6) A Game of Thrones, George R. R. Martin, 864

問5 sedを使用してbook.txt内の「,」を全部消してください。

[user01@localhost ~]$ sed ??? books.txt
1) A Storm of Swords George R. R. Martin 1216
2) The Two Towers J. R. R. Tolkien 352
3) The Alchemist Paulo Coelho 197
4) The Fellowship of the Ring J. R. R. Tolkien 432
5) The Pilgrimage Paulo Coelho 288
6) A Game of Thrones George R. R. Martin 864

NEXT>> 11章 AWK