How do I count the number of rows and columns in a file using bash?

后端 未结 13 702
情深已故
情深已故 2020-12-23 03:09

Say I have a large file with many rows and many columns. I\'d like to find out how many rows and columns I have using bash.

13条回答
  •  再見小時候
    2020-12-23 03:49

    Columns: awk '{print NF}' file | sort -nu | tail -n 1

    Use head -n 1 for lowest column count, tail -n 1 for highest column count.

    Rows: cat file | wc -l or wc -l < file for the UUOC crowd.

提交回复
热议问题