使用linux终端访问.dbf的数据

时间:2014-12-15 18:20:40

标签: linux scripting terminal sh dbf

假设我有一个包含3行的.dbf文件,每行包含5(E)列数据

是否可以使用终端命令查找:

  • 这个.dbf文件有多少行数据? (3,将此号码打印到终端)

  • 特定细胞存储的数据是什么? (例如:2C中有字符串“Hello”,打印“Hello”到终端)

我在考虑使用grep,但我不确定如何在.dbf上正确使用它

1 个答案:

答案 0 :(得分:0)

dbf个文件是专门的二进制格式文件。因此,需要使用专门的工具来处理它。

如果您不介意学习一点编程,可以使用Python和我的dbf library来编写这样简单的命令。

这是打印长度的示例脚本:

#!/usr/bin/env python
# this prints the number of rows in the dbf listed on the command line

import sys
import dbf

table = dbf.Table(sys.argv[1])
print(len(table))