TimiZheng 发表于 2019-9-27 14:01:24

给力的linux命令--parallel安装

GNU parallel是并行执行任务的shell工具。在文章情景linux—shell如何实现多线程?中提到了它的一种用法,但这远远不够,它还有许多更强大的应用场景。但在此之前,需要先安装它。 下载<font color="black" size="2">$ wget http://ftp.gnu.org/gnu/parallel/parallel-latest.tar.bz2
--2017-06-23 19:00:03--http://ftp.gnu.org/gnu/parallel/parallel-latest.tar.bz2
Resolving ftp.gnu.org... 208.118.235.20, 2001:4830:134:3::b
Connecting to ftp.gnu.org|208.118.235.20|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1559659 (1.5M)
Saving to: “parallel-latest.tar.bz2”

100%[=============================>] 1,559,659   4.46K/s   in 6m 19s

2017-06-23 19:06:23 (4.02 KB/s) - “parallel-latest.tar.bz2” saved </font>查看下载到的文件:$ ll
-rw-rw-r-- 1 j-tester j-tester 1559659 Jun 22 20:06 parallel-latest.tar.bz2解压下载的文件tar -jvx -f parallel-latest.tar.bz2 -C ./
parallel-20170622/
parallel-20170622/COPYING
parallel-20170622/NEWS
parallel-20170622/configure
parallel-20170622/CITATION
parallel-20170622/missing
parallel-20170622/install-sh
parallel-20170622/src/
parallel-20170622/src/sem.pod
parallel-20170622/src/parset
parallel-20170622/src/parallel_tutorial.7
parallel-20170622/src/parallel_tutorial.pdf
parallel-20170622/src/parallel_alternatives.7
parallel-20170622/src/env_parallel.bash
parallel-20170622/src/parallel_alternatives.html
parallel-20170622/src/niceload.pdf
parallel-20170622/src/parset.pdf
parallel-20170622/src/parallel_design.pod
parallel-20170622/src/niceload.1
parallel-20170622/src/env_parallel
parallel-20170622/src/parset.pod
parallel-20170622/src/sem
parallel-20170622/src/env_parallel.html
parallel-20170622/src/env_parallel.pdf
parallel-20170622/src/niceload
parallel-20170622/src/parcat.pod
parallel-20170622/src/sql.pdf
parallel-20170622/src/parcat.texi
parallel-20170622/src/env_parallel.tcsh
parallel-20170622/src/sem.pdf
parallel-20170622/src/env_parallel.sh
parallel-20170622/src/niceload.html
parallel-20170622/src/parallel_design.7
parallel-20170622/src/env_parallel.ash
parallel-20170622/src/parallel_tutorial.texi
parallel-20170622/src/env_parallel.1
parallel-20170622/src/parallel.html
parallel-20170622/src/parallel_tutorial.pod
parallel-20170622/src/sql.1
parallel-20170622/src/parcat.html
parallel-20170622/src/parset.1
parallel-20170622/src/env_parallel.pod
parallel-20170622/src/parallel.pdf
parallel-20170622/src/env_parallel.texi
parallel-20170622/src/env_parallel.csh
parallel-20170622/src/niceload.pod
parallel-20170622/src/env_parallel.ksh
parallel-20170622/src/parcat
parallel-20170622/src/env_parallel.pdksh
parallel-20170622/src/parallel_design.pdf
parallel-20170622/src/env_parallel.zsh
parallel-20170622/src/parallel_alternatives.pod
parallel-20170622/src/parcat.pdf
parallel-20170622/src/Makefile.am
parallel-20170622/src/parcat.1
parallel-20170622/src/sem.texi
parallel-20170622/src/parallel_design.texi
parallel-20170622/src/parallel_alternatives.pdf
parallel-20170622/src/parallel
parallel-20170622/src/parset.texi
parallel-20170622/src/parallel_alternatives.texi
parallel-20170622/src/niceload.texi
parallel-20170622/src/parallel.texi
parallel-20170622/src/parallel.1
parallel-20170622/src/sql.html
parallel-20170622/src/sem.html
parallel-20170622/src/env_parallel.dash
parallel-20170622/src/parallel_design.html
parallel-20170622/src/env_parallel.fish
parallel-20170622/src/Makefile.in
parallel-20170622/src/sql.texi
parallel-20170622/src/sql
parallel-20170622/src/parallel.pod
parallel-20170622/src/parset.html
parallel-20170622/src/sem.1
parallel-20170622/src/parallel_tutorial.html
parallel-20170622/config.h.in
parallel-20170622/README
parallel-20170622/aclocal.m4
parallel-20170622/CREDITS
parallel-20170622/Makefile.am
parallel-20170622/configure.ac
parallel-20170622/Makefile.in进入解压后的文件夹cd parallel-20170622/
total 388
-rw-rw-r-- 1 j-tester j-tester28344 Jun 22 19:43 aclocal.m4
-rw-rw-r-- 1 j-tester j-tester    631 May1 15:05 CITATION
-rw-rw-r-- 1 j-tester j-tester    625 Jun 22 19:43 config.h.in
-rwxrwxr-x 1 j-tester j-tester 110321 Jun 22 19:43 configure
-rw-rw-r-- 1 j-tester j-tester    442 Jun 22 19:35 configure.ac
-rw-rw-r-- 1 j-tester j-tester35147 May1 15:05 COPYING
-rw-rw-r-- 1 j-tester j-tester   1810 May1 15:05 CREDITS
-rwxr-xr-x 1 j-tester j-tester15155 Jun 22 19:43 install-sh
-rw-rw-r-- 1 j-tester j-tester   4733 May1 15:05 Makefile.am
-rw-rw-r-- 1 j-tester j-tester28687 Jun 22 19:43 Makefile.in
-rwxr-xr-x 1 j-tester j-tester   6872 Jun 22 19:43 missing
-rw-rw-r-- 1 j-tester j-tester 130719 Jun 22 19:45 NEWS
-rw-rw-r-- 1 j-tester j-tester   3525 Jun 22 19:35 README
drwxrwxr-x 2 j-tester j-tester   4096 Jun 22 19:45 src生成Makefile$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether ln -s works... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating config.h编译make -j4
makeall-recursive
make: Entering directory `/home/j-tester/bin/multiple_process/parallel-20170622'
Making all in src
make: Entering directory `/home/j-tester/bin/multiple_process/parallel-20170622/src'
make: Nothing to be done for `all'.
make: Leaving directory `/home/j-tester/bin/multiple_process/parallel-20170622/src'
make: Entering directory `/home/j-tester/bin/multiple_process/parallel-20170622'
make: Leaving directory `/home/j-tester/bin/multiple_process/parallel-20170622'
make: Leaving directory `/home/j-tester/bin/multiple_process/parallel-20170622'



来源:公众号软件测试技能站;作者:signjing(博为峰网校金牌讲师)

TimiZheng 发表于 2019-9-27 14:02:18

安装
sudo make install -j 16
Making install in src
make: Entering directory `/home/j-tester/bin/multiple_process/parallel-20170622/src'
make: Entering directory `/home/j-tester/bin/multiple_process/parallel-20170622/src'
/bin/mkdir -p '/usr/local/bin'
/bin/mkdir -p '/usr/local/share/doc/parallel'
/bin/mkdir -p '/usr/local/share/man/man1'
/bin/mkdir -p '/usr/local/share/man/man7'
/usr/bin/install -c parallel sql niceload parcat env_parallel env_parallel.ash env_parallel.bash env_parallel.csh env_parallel.dash env_parallel.fish env_parallel.ksh env_parallel.pdksh env_parallel.sh env_parallel.tcsh env_parallel.zsh '/usr/local/bin'
/usr/bin/install -c -m 644 parallel.html env_parallel.html sem.html sql.html niceload.html parallel_tutorial.html parallel_design.html parallel_alternatives.html parcat.html parset.html parallel.texi env_parallel.texi sem.texi sql.texi niceload.texi parallel_tutorial.texi parallel_design.texi parallel_alternatives.texi parcat.texi parset.texi parallel.pdf env_parallel.pdf sem.pdf sql.pdf niceload.pdf parallel_tutorial.pdf parallel_design.pdf parallel_alternatives.pdf parcat.pdf parset.pdf '/usr/local/share/doc/parallel'
/usr/bin/install -c -m 644 parallel.1 env_parallel.1 sem.1 sql.1 niceload.1 parcat.1 parset.1 '/usr/local/share/man/man1'
/usr/bin/install -c -m 644 parallel_tutorial.7 parallel_design.7 parallel_alternatives.7 '/usr/local/share/man/man7'
makeinstall-exec-hook
make: Entering directory `/home/j-tester/bin/multiple_process/parallel-20170622/src'
rm /usr/local/bin/sem || true
rm: cannot remove `/usr/local/bin/sem': No such file or directory
ln -s parallel /usr/local/bin/sem
make: Leaving directory `/home/j-tester/bin/multiple_process/parallel-20170622/src'
make: Leaving directory `/home/j-tester/bin/multiple_process/parallel-20170622/src'
make: Leaving directory `/home/j-tester/bin/multiple_process/parallel-20170622/src'
make: Entering directory `/home/j-tester/bin/multiple_process/parallel-20170622'
make: Entering directory `/home/j-tester/bin/multiple_process/parallel-20170622'
make: Nothing to be done for `install-exec-am'.
make: Nothing to be done for `install-data-am'.
make: Leaving directory `/home/j-tester/bin/multiple_process/parallel-20170622'
make: Leaving directory `/home/j-tester/bin/multiple_process/parallel-20170622'

TimiZheng 发表于 2019-9-27 14:03:58

测试安装后的效果
whereis parallel
parallel: /usr/local/bin/parallel
$ parallel --help
Usage:

parallel ] < list_of_arguments
parallel ] (::: arguments|:::: argfile(s))...
cat ... | parallel --pipe ]

-j n            Run n jobs in parallel
-k            Keep same order
-X            Multiple arguments with context replace
--colsep regexp Split input on regexp for positional replacements
{} {.} {/} {/.} {#} {%} {= perl code =} Replacement strings
{3} {3.} {3/} {3/.} {=3 perl code =}    Positional replacement strings
With --plus:    {} = {+/}/{/} = {.}.{+.} = {+/}/{/.}.{+.} = {..}.{+..} =
                {+/}/{/..}.{+..} = {...}.{+...} = {+/}/{/...}.{+...}

-S sshlogin   Example: foo@server.example.com
--slf ..      Use ~/.parallel/sshloginfile as the list of sshlogins
--trc {}.bar    Shorthand for --transfer --return {}.bar --cleanup
--onall         Run the given command with argument on all sshlogins
--nonall      Run the given command with no arguments on all sshlogins

--pipe          Split stdin (standard input) to multiple jobs.
--recend str    Record end separator for --pipe.
--recstart strRecord start separator for --pipe.

See 'man parallel' for details

Academic tradition requires you to cite works you base your article on.
When using programs that use GNU Parallel to process data for publication
please cite:

O. Tange (2011): GNU Parallel - The Command-Line Power Tool,
;login: The USENIX Magazine, February 2011:42-47.

This helps funding further development; AND IT WON'T COST YOU A CENT.
If you pay 10000 EUR you should feel free to use GNU Parallel without citing.

参考链接
https://www.gnu.org/software/parallel/
情景linux—shell如何实现多线程?
页: [1]
查看完整版本: 给力的linux命令--parallel安装