how to read file from line x to the end of a file in bash

前端 未结 7 496
慢半拍i
慢半拍i 2020-12-23 13:33

I would like know how I can read each line of a csv file from the second line to the end of file in a bash script.

I know how to read a file in bash:

7条回答
  •  旧巷少年郎
    2020-12-23 14:09

    tail -n +2 file.csv
    

    From the man page:

    -n, --lines=N
         output the last N lines, instead of the last 10
    ...
    
    If the first character of N (the number of bytes or lines)  is  a  '+',
    print  beginning with the Nth item from the start of each file, other-
    wise, print the last N items in the file.
    

    In English this means that:

    tail -n 100 prints the last 100 lines

    tail -n +100 prints all lines starting from line 100

提交回复
热议问题