Linux command (like cat) to read a specified quantity of characters

前端 未结 9 2051
梦谈多话
梦谈多话 2020-12-12 15:53

Is there a command like cat in linux which can return a specified quantity of characters from a file?

e.g., I have a text file like:

Hel         


        
9条回答
  •  [愿得一人]
    2020-12-12 16:37

    head or tail can do it as well:

    head -c X

    Prints the first X bytes (not necessarily characters if it's a UTF-16 file) of the file. tail will do the same, except for the last X bytes.

    This (and cut) are portable.

提交回复
热议问题