xargs

GNU parallel not working at all

会有一股神秘感。 提交于 2019-12-17 05:00:16
问题 I have been trying to use GNU parallel for some time, but I have never been able to get it to function at all! For example, running (in a non-empty directory!): ls | parallel echo # Outputs single new line ls | parallel echo echo echo # Outputs three new lines. ls | parallel echo {} # /bin/bash: {}: command not found ls | parallel echo '{}' # /bin/bash: {}: command not found ls | parallel 'echo {}' # Outputs: {} ls | parallel -IMM 'echo MM' # Outputs: MM It seems that it is simply executing

Calling shell functions with xargs

感情迁移 提交于 2019-12-17 03:26:36
问题 I am trying to use xargs to call a more complex function in parallel. #!/bin/bash echo_var(){ echo $1 return 0 } seq -f "n%04g" 1 100 |xargs -n 1 -P 10 -i echo_var {} exit 0 This returns the error xargs: echo_var: No such file or directory Any ideas on how I can use xargs to accomplish this, or any other solution(s) would be welcome. 回答1: Exporting the function should do it (untested): export -f echo_var seq -f "n%04g" 1 100 | xargs -n 1 -P 10 -I {} bash -c 'echo_var "$@"' _ {} You can use

Linux Centos7 删除MySQL

南楼画角 提交于 2019-12-14 09:00:15
1.找到所有mysql包 rpm - qa | grep mysql 2.rpm命令删除mysql包 rpm - qa | grep mysql | xargs - p rpm - evh 3.查看其余mysql文件 find / - name mysql 4.删除所有其余mysql文件 find / - name mysql | xargs - p rm - f xargs命令解释: https://www.cnblogs.com/wangqiguo/p/6464234.html 来源: CSDN 作者: 超大玉螺旋丸 链接: https://blog.csdn.net/qq_38534191/article/details/103470381

Don't call xargs if the previous command doesn't return anything [duplicate]

我只是一个虾纸丫 提交于 2019-12-14 03:56:51
问题 This question already has answers here : How to ignore xargs commands if stdin input is empty? (6 answers) Closed 2 years ago . I have the following command that checks if any new files are added and automatically calls svn add on all these files svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add But when there are no files, svn add results in a warning. How to stop from xargs from getting called the previous command doesn't result in any values? The solution

Making Python scripts work with xargs

梦想与她 提交于 2019-12-14 00:52:41
问题 What would be the process of making my Python scripts work well with 'xargs'? For instance, I would like the following command to work through each line of text file, and execute an arbitrary command: cat servers.txt | ./hardware.py -m Essentially would like each line to be passed to the hardware.py script. 回答1: To make your commands work with xargs you simply need them to accept arguments. Arguments in Python are in the sys.argv list. In this way you can execute somthing like: find . -type f

Explicit sort parallelization via xargs — Incomplete results from xargs --max-procs

一笑奈何 提交于 2019-12-13 19:41:52
问题 Context I need to optimize deduplication using 'sort -u' and my linux machine has an old implementation of 'sort' command (i.e. 5.97) that has not '--parallel' option. Although 'sort' implements parallelizable algorithms (e.g. merge-sort), I need to make such parallelization explicit. Therefore, I make it by hand via 'xargs' command that outperforms ~2.5X w.r.t. to the single 'sort -u' method ... when it works fine. Here the intuition of what I am doing. I am running a bash script that splits

Linux Shell 文本处理工具集锦

杀马特。学长 韩版系。学妹 提交于 2019-12-13 07:42:24
来自:me115, www.cnblogs.com/me115/p/3427319.html 本文将介绍Linux下使用Shell处理文本时最常用的工具: find、grep、xargs、sort、uniq、tr、cut、paste、wc、sed、awk; 提供的例子和参数都是最常用和最为实用的; 我对shell脚本使用的原则是命令单行书写,尽量不要超过2行; 如果有更为复杂的任务需求,还是考虑python吧; find 文件查找 查找txt和pdf文件 find . \ ( -name "*.txt" -o -name "*.pdf" \ ) -print 正则方式查找.txt和pdf find . -regex ".*\(\.txt|\.pdf\)$" -iregex:忽略大小写的正则 否定参数 查找所有非txt文本 find . ! -name "*.txt" -print 指定搜索深度 打印出当前目录的文件(深度为1) find . -maxdepth 1 -type f 定制搜索 按类型搜索: find . -type d -print //只列出所有目录 -type f 文件 / l 符号链接 按时间搜索: -atime 访问时间 (单位是天,分钟单位则是-amin,以下类似) -mtime 修改时间 (内容被修改) -ctime 变化时间 (元数据或权限变化)

Search files and run a script on every result

佐手、 提交于 2019-12-13 03:35:44
问题 I would like to know how to search certain pattern of files in all Sub Directories ( Month wise / Date wise - Sub Directories created). And then, execute a script on the found files. Step1: For example: currently searching files on this pattern TT_DETAIL*.gz . find /cygdrive/c/Test/ -name TT_DETAIL*.gz output#1: /cygdrive/c/Test/Feb2014/TT_DETAIL_20141115.csv.gz /cygdrive/c/Test/Jan2014/TT_DETAIL_20141110.csv.gz /cygdrive/c//Test/Mar2014/TT_DETAIL_20141120.csv.gz Step2: zcat TT_DETAIL*.gz |

How can I pass multiple sub-commands to xargs when using the parallel option

不问归期 提交于 2019-12-13 01:25:44
问题 I'm trying to write a bash script to process a large directory tree and rsync that in multiple streams. From other research on this site I constructed the following. The assumption is the command is run: program.sh /input/location /output/location $threads The key line in my script is cd $1; find . -depth \( -type d -printf \""%p/\"\n" \) | xargs -n1 -P$3 -I% rsync -lptgoDds --delete --backup --backup-dir=$INCREMENTALS/$DATE/$1 % $2/% The idea of the above is to find all the directories at a

WGET - Simultaneous connections are SLOW

匆匆过客 提交于 2019-12-12 22:20:46
问题 I use the following command to append the browser's response from list of URLs into an according output file: wget -i /Applications/MAMP/htdocs/data/urls.txt -O - \ >> /Applications/MAMP/htdocs/data/export.txt This works fine and when finished it says: Total wall clock time: 1h 49m 32s Downloaded: 9999 files, 3.5M in 0.3s (28.5 MB/s) In order to speed this up I used: cat /Applications/MAMP/htdocs/data/urls.txt | \ tr -d '\r' | \ xargs -P 10 $(which wget) -i - -O - \ >> /Applications/MAMP