unix - head AND tail of file

前端 未结 20 1285
误落风尘
误落风尘 2020-12-07 11:05

Say you have a txt file, what is the command to view the top 10 lines and bottom 10 lines of file simultaneously?

i.e. if the file is 200 lines long, then view lines

20条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 11:39

    Well, you can always chain them together. Like so, head fiename_foo && tail filename_foo. If that is not sufficient, you could write yourself a bash function in your .profile file or any login file that you use:

    head_and_tail() {
        head $1 && tail $1
    }
    

    And, later invoke it from your shell prompt: head_and_tail filename_foo.

提交回复
热议问题