从在bash空格分隔的CSV文件中查找特定的细胞 [英] Find specific cell from space-separated CSV file in bash
本文介绍了从在bash空格分隔的CSV文件中查找特定的细胞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有相关的问题来砸在逗号分隔值文件(.CSV)保存空间作为选择的分离操作。
I have a question related to bash operating on comma-separated value files (.csv) saved with spaces as the selected separator.
作为一个例子,我会在这里把小.csv文件:
As an example I'll put small .csv file here:
A B C D
1 a b c d
2 e f g h
3 i j k l
4 m n o p
这是我的问题:这有可能在bash从小区C4例如读取特定值
And here is my question: Is that possible in bash to read specific value for example from cell C4?
试图找到类似的问题,任何话题,但不就可以了。
Tried to find any topic with similar problem but cannot it.
在此先感谢!
推荐答案
在可以AWK做到这一点很容易:
Can do this very easily in awk :
example.sh
#!/bin/bash
awk '
{
if(NR==5){ print $4; }
}
' < "$1"
输出
$ ./example.sh input.txt
o
详情
- NR过滤行号
- $ 4.指第四场(在C柱)
这篇关于从在bash空格分隔的CSV文件中查找特定的细胞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文