bash - 使用 gnu-parallel 处理文件内容
问题描述
我有一个文件,内容如下:
/path/to/file1
/path/to/file2
/path/to/file3
/path/to/file4
我想使用该gnu-parallel
实用程序在每一行上并行运行一个命令,我知道该实用程序支持使用::::
. 我不确定的是我应该将哪些参数传递给 gnu-parallel 以拆分文件内容\n
并并行处理?
解决方案
这是man parallel
:
NAME
parallel - build and execute shell command lines from
standard input in parallel
SYNOPSIS
parallel [options] [command [arguments]] < list_of_arguments
[...]
这是这种调用形式的示例:
$ cat mylist.txt
/path/to/file1
/path/to/file2
/path/to/file3
/path/to/file4
$ parallel 'echo "I am processing:" {}' < mylist.txt
I am processing: /path/to/file1
I am processing: /path/to/file2
I am processing: /path/to/file3
I am processing: /path/to/file4
推荐阅读
- sql - 需要 regex_extract SQL 查询以返回“开头”和“结尾”某个字符的值
- node.js - out-ping nodejs包安装错误
- javascript - 如何使用 Vue 在 Vue 中创建通用函数?
- javascript - 当 setimeout == 0 时更改页面
- c# - 在实体框架中配置多对多关系时出现“歧义引用”错误
- anaconda - 为什么 conda 不删除已删除环境的软件包?
- html - 翻转卡不会在移动设备上翻转
- vue.js - 将 Vuex 与子组件一起使用的正确方法
- powershell - 让私钥在 Windows 7 powershell 版本 2 上工作
- intellij-idea - 如何在不是我当前所在目录的目录中添加新文件(通过键盘,而不是鼠标)?