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

前端 未结 9 2055
梦谈多话
梦谈多话 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:44

    I know the answer is in reply to a question asked 6 years ago ...

    But I was looking for something similar for a few hours and then found out that: cut -c does exactly that, with an added bonus that you could also specify an offset.

    cut -c 1-5 will return Hello and cut -c 7-11 will return world. No need for any other command

提交回复
热议问题