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

后端 未结 13 1230
深忆病人
深忆病人 2020-12-23 03:07

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:55

    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.

提交回复
热议问题