Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 如何在Ubuntu中使用ripgrep搜索CSV文件中的行_Shell_Ubuntu_Grep_Ripgrep - Fatal编程技术网

Shell 如何在Ubuntu中使用ripgrep搜索CSV文件中的行

Shell 如何在Ubuntu中使用ripgrep搜索CSV文件中的行,shell,ubuntu,grep,ripgrep,Shell,Ubuntu,Grep,Ripgrep,我的主目录中有一个csv文件,如下所示 cat try.csv val1,val2,val3,val4,val5,val6 10-Jul-19,12604876601113439,Self,abs,Tier-I,30088.5 09-Jul-19,12604876601112397,Self,abs,Tier-I,200590 08-Jul-19,12604876601111807,Self,abs,Tier-I,200590 05-Jul-19,12604876601109069,Self,a

我的主目录中有一个csv文件,如下所示

cat try.csv
val1,val2,val3,val4,val5,val6
10-Jul-19,12604876601113439,Self,abs,Tier-I,30088.5
09-Jul-19,12604876601112397,Self,abs,Tier-I,200590
08-Jul-19,12604876601111807,Self,abs,Tier-I,200590
05-Jul-19,12604876601109069,Self,abs,Tier-I,70206.5
29-May-19,12604876601085648,Self,cdf,Tier-I,70206.5
30-Apr-19,12604876601068094,Self,cdf,Tier-I,130383.5
15-Nov-18,12604876600900949,Self,xyz,Tier-I,71209.46
10-Oct-18,12604876600887501,Self,xyz,Tier-I,79233.06
我可以使用
grep
命令提取包含单词“abs”的行:

然而,我遇到了
ripgrep
,其中声称具有与
grep
类似的功能,但执行速度更快(我的实际csv文件非常大,大小为30gb,因此我需要比
grep
更快的方法)

因此,我安装了
ripgrep
cargo install ripgrep
并在代码下面运行

ripgrep -w 'abs' try.csv
但我犯了错误

Command 'ripgrep' not found, did you mean:

  command 'sipgrep' from deb sipgrep
  command 'zipgrep' from deb unzip

Try: apt install <deb name>
未找到命令“ripgrep”,您的意思是:
来自deb sipgrep的命令“sipgrep”
命令'zipgrep'从deb解压
尝试:apt安装

任何以正确方式使用ripgrep的指针都会有帮助

该程序称为
ripgrep
,但它是由
rg
调用的。您需要做的只是:

rg-w'abs'try.csv

如果速度更快,请告诉我们。祝你好运。我看不出有什么大的进步。但是,如果您可以重新组织文件,以便可以使用行首定位或行尾定位reg ex(
^
$
),我愿意接受任何其他加快处理27gb文件的选项,这可能会有所帮助。或者将其分为多个部分交付,然后您可以使用
gnuparallel
运行多个grep。你不会比基本grep快很多,它的优化C代码(40多年了)。祝你好运。ripgrep在很多情况下都比基本的grep快。请参阅基准。但是,如果您的文件是27GB,并且不能全部放入内存,那么您很可能会因为底层I/O设备的速度而被阻塞。ripgrep无法神奇地加快速度。
Command 'ripgrep' not found, did you mean:

  command 'sipgrep' from deb sipgrep
  command 'zipgrep' from deb unzip

Try: apt install <deb name>