开发者

how to look at txt file at 10-20-30-40-50-60-70-80-90 percent marks?

I have a large txt file, using CLI I can take a look at the beginning of the file using"

head file.txt

at the end:

tail file.txt

How do I take a look at the 10 percent of the file, 20 开发者_StackOverflowpercent of the file, etc?


Note that

  • in the GNU less pager you can simply type 50%Enter and go there
  • vim has the same feature in normal mode (not in Vi)

    {count}% Go to {count} percentage in the file, on the first non-blank in the line |linewise|. To compute the new line number this formula is used: ({count} * number-of-lines + 99) / 100 See also 'startofline' option. {not in Vi}

This, for my purposes, removes all need for such a thing


You can create an alias for "mid" to select a range of lines.

As for percentages, you'll probably need a script instead of a one liner so that you determine how many lines are in the file and then what line 10% starts at

alias mid 'tail -n +\!:1 \!:3* | head -n \!:2'

See: http://www.fastechws.com/tricks/unix/head_tail_mid_files.php

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜