开发者

HowTo view text file from the bottom on *nix?

I'm looking a simple command, like

$ less -{view_from_bottom_of_th开发者_如何学JAVAe_file_option} filename

or

$ vi -{start_viewer_from_the_bottom} filename

viewer, editor - what ever.

Thanks.


vi + filename (open the file filename at the last line)

or

vi +lineNumber filename (e.g. to open the file with filename at line 100, vi +100 filename)


tac $file | less

will reverse the order of the lines


You can use the +[num] command line option of vim.

+[num]  The cursor will be positioned on line "num" for the first
        file being edited.  If "num" is missing, the cursor will be
        positioned on the last line.

So to palce the cursor at the last line you can do:

vim + file_name


tail -n [lines] [file] will output the last [lines] of the [file]. When you add -f, the file will not be closed and you will see updates which are appended at the file.


less (on linux, FreeBSD, MacOSX) has the + option to send initial commands to less. An example in the man page uses it exactly to start viewing the file at last line. Like this:

less +G filename
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜