How do I read the first line of a file using cat?

前端 未结 11 780
渐次进展
渐次进展 2021-01-29 22:20

How do I read the first line of a file using cat?

相关标签:
11条回答
  • 2021-01-29 22:44

    You don't need cat.

    head -1 file
    

    will work fine.

    0 讨论(0)
  • 2021-01-29 22:46

    You could use cat file.txt | head -1, but it would probably be better to use head directly, as in head -1 file.txt.

    0 讨论(0)
  • 2021-01-29 22:46

    Use the below command to get the first row from a CSV file or any file formats.

    head -1 FileName.csv
    
    0 讨论(0)
  • 2021-01-29 22:54

    cat alone may not be possible, but if you don't want to use head this works:

     cat <file> | awk 'NR == 1'
    
    0 讨论(0)
  • 2021-01-29 22:56

    You don't, use head instead.

    head -n 1 file.txt
    
    0 讨论(0)
提交回复
热议问题