管道命令不起作用

管道命令不起作用

我尝试执行这个管道命令,但没有作用。

find /home/siddath/enron -name "*" -print | \ parallel python email_parser.py {} > from_to.txt 
No command ' parallel' found, did you mean:
 Command 'parallel' from package 'parallel' (universe)
 Command 'parallel' from package 'moreutils' (universe)
 parallel: command not found

我使用并行安装

sudo apt-get install parallel

输出为apt-cache policy parallel perl

parallel:
  Installed: 20130922-1
  Candidate: 20130922-1
  Version table:
 *** 20130922-1 0
        500 http://in.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
        100 /var/lib/dpkg/status
perl:
  Installed: 5.18.2-2ubuntu1
  Candidate: 5.18.2-2ubuntu1.1
  Version table:
     5.18.2-2ubuntu1.1 0
        500 htp://in.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
        500 htp://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
 *** 5.18.2-2ubuntu1 0
        500 http://in.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
        100 /var/lib/dpkg/status

运行命令后find /home/siddath/enron | parallel python email_parser.py {} > from_to.txt我得到:

defined(@array) is deprecated at /usr/local/bin/parallel line 120.
    (Maybe you should just omit the defined()?)
defined(@array) is deprecated at /usr/local/bin/parallel line 580.
    (Maybe you should just omit the defined()?)
defined(@array) is deprecated at /usr/local/bin/parallel line 626.
    (Maybe you should just omit the defined()?)

有什么问题?

更新: 的输出type -a parallel

parallel is /usr/local/bin/parallel
parallel is /usr/bin/parallel

更改 /usr/local/bin/parallel 的权限后:sudo chmod -x /usr/local/bin/parallel

siddath@SID:~/enronscript$ find /home/siddath/enron | parallel python email_parser.py {} > from_to.txt
bash: /usr/local/bin/parallel: Permission denied

我导航到的路径如下:

siddath@SID:/usr/local/bin$ find /home/siddath/enron | parallel python email_parser.py {} > from_to.txt 
bash: from_to.txt: Permission denied

我是否需要在此目录中创建一个文件来执行 find/parallel 命令,或者是否有其他方法可以使其工作?

答案1

正确的命令应该是这样的:

find /home/siddath/enron | parallel python email_parser.py {} > from_to.txt

我做了什么?

  • 在管道之后,您写入\ parallel- 这与运行 相同' parallel',两种方式都在开头包含一个空格作为命令的一部分。当然,此命令不存在,因此无法找到。只需删除 即可\解决该问题。
  • 您写了find /any/directory -name "*" -print,但-print已经是默认操作,如果未指定任何过滤器,它会查找所有文件和目录 - 与此通用通配符过滤器相​​同-name "*"。因此,您可以省略两个参数,而只需写入find /any/directory即可。

相关内容