Search code examples
linuxfilebashtail

How to take a specific part of a line in a file using shell commands?


I would like to take a specific part of the last line of a file. say the values between "cursor position" 9 and 22? to take the last line I know I should use tail -1 but and the second part?


Solution

  • I think GNU cut can get you there. For example:

    cut -c 9-22
    

    Or, in total:

    tail -1 file | cut -c 9-22