Linux's head selects a number of lines from the top of a file. Is there a command that selects a number of characters from the front of a line?

The use case behind the question is this: I want to head the first 10 lines from a file, but each of those 10 lines is extremely long and contain lots of white space, making it hard to discern where the line breaks are.

It would be much easier to get a general idea of the contents of the file if I could head the first 10 lines, but only view the first 50 characters of each line.

  • 1
    See also tput rmam to disable the terminal's wrapping or piping the output to less -S, or :set nowrap in vi. Jul 2, 2018 at 12:15

1 Answer 1


Try cut:

head -n 10 bigfile | cut -c 1-50
  • 1
    redirection isn't needed here...cut -c 1-50 bigfile | head -n 10 is IMO more readable.
    – cas
    Oct 3, 2012 at 22:34
  • 1
    I've been searching Google for about 3 hours for an answer to this question, it's to simple to create an actual question for it though. I would like to know which way is preferred between "-c 1-50" vs. "-c1-50" (based on the extra space between the argument and the value I suppose) would you happen to know which way is preferred?
    – Jacob
    Oct 25, 2012 at 1:11
  • @Jacob Based on the POSIX argument and syntax guidelines and the POSIX spec for cut, I'd always include a space (it helps readability as well), although it seems that omitting the blank should still work.
    – jw013
    Oct 25, 2012 at 4:36
  • @jw013 thanks for your answer and the links, that's exactly what I was looking for.
    – Jacob
    Oct 25, 2012 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.