1

On Linux in a bash shell, I have a text file with long lines and would like to look at the first few characters of the the first few lines. Thus, I need something like head, but with the ability to limit the number of characters printed per line.

What would the simplest way to do this?

loris
  • 232
  • 1
  • 12

1 Answers1

4

cat /etc/passwd| cut -b -6 will give you the first 6 characters of each line of /etc/passwd file

You may add a | head -9 to read only the first nine lines.

Dom
  • 6,743
  • 1
  • 20
  • 24
  • I actually went for ```head file_with_long_lines.txt | cut -c -80```, so characters rather than bytes. – loris Mar 29 '23 at 13:55