如何使用bash计算文件中的行数和列数? [英] How do I count the number of rows and columns in a file using bash?

查看:84
本文介绍了如何使用bash计算文件中的行数和列数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有一个很大的文件,其中包含许多行和许多列.我想找出使用​​bash有多少行和列.

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.

推荐答案

列: awk'{print NF}'文件|排序-nu |尾-n 1

使用 head -n 1 表示最低列数, tail -n 1 表示最大列数.

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

行: cat文件|wc -l <​​/code>或 wc -l< UUOC 人群的文件.

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

这篇关于如何使用bash计算文件中的行数和列数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆