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

后端 未结 13 1244
深忆病人
深忆病人 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:44

    head -1 file.tsv |head -1 train.tsv |tr '\t' '\n' |wc -l
    

    take the first line, change tabs (or you can use ',' instead of '\t' for commas), count the number of lines.

提交回复
热议问题