xargs

Which is faster, 'find -exec' or 'find | xargs -0'?

隐身守侯 提交于 2019-11-30 20:34:52
In my web application I render pages using PHP script, and then generate static HTML files from them. The static HTML are served to the users to speed up performance. The HTML files become stale eventually, and need to be deleted. I am debating between two ways to write the eviction script. The first is using a single find command, like find /var/www/cache -type f -mmin +10 -exec rm \{} \; The second form is by piping through xargs, something like find /var/www/cache -type f -mmin +10 -print0 | xargs -0 rm The first form invokes rm for each file it finds, while the second form just sends all

Bash - how to unzip a piped zip file (from “wget -qO-”)

五迷三道 提交于 2019-11-30 16:25:46
问题 Any ideas on how to unzip a piped zip file like this: wget -qO- http://downloads.wordpress.org/plugin/akismet.2.5.3.zip I wished to unzip the file to a directory, like we used to do with a normal file: wget -qO- http://downloads.wordpress.org/plugin/akismet.2.5.3.zip | unzip -d ~/Desktop 回答1: wget -q -O tmp.zip http://downloads.wordpress.org/plugin/akismet.2.5.3.zip && unzip tmp.zip && rm tmp.zip 回答2: The ZIP file format includes a directory (index) at the end of the archive. This directory

xargs: losing output when redirecting stdout to a file in parallel mode

烂漫一生 提交于 2019-11-30 14:46:28
I am using GNU xargs (version 4.2.2) in parallel mode and I seem to be reliably losing output when redirecting to a file. When redirecting to a pipe, it appears to work correctly. The following shell commands demonstrates a minimum, complete, and verifiable example of the issue. I generate 2550 numbers using xargs to split it into lines of 100 args each totalling 26 lines where the 26th line contains only 50 args. # generate numbers 1 to 2550 where each number is on its own line $ seq 1 2550 > /tmp/nums $ wc -l /tmp/nums 2550 /tmp/nums # piping to wc is accurate: 26 lines, 2550 args $ xargs

How can I use adb to uninstall all 3rd party user apps?

ぐ巨炮叔叔 提交于 2019-11-30 14:17:57
问题 I am trying to create a script that will retrieve and uninstall all user apps in one batch operation through adb . Does anyone know how I would be able to do this? I can currently list out all 3rd party apps through adb shell pm list packages -3 Could I somehow direct the list of packages this generates into an uninstall command in adb ? 回答1: Try: adb shell pm list packages -3 | cut -d':' -f2 | tr '\r' ' ' | xargs -r -n1 -t adb uninstall First part is to get 3rd party app package names second

How can I use adb to uninstall all 3rd party user apps?

荒凉一梦 提交于 2019-11-30 10:15:00
I am trying to create a script that will retrieve and uninstall all user apps in one batch operation through adb . Does anyone know how I would be able to do this? I can currently list out all 3rd party apps through adb shell pm list packages -3 Could I somehow direct the list of packages this generates into an uninstall command in adb ? Try: adb shell pm list packages -3 | cut -d':' -f2 | tr '\r' ' ' | xargs -r -n1 -t adb uninstall First part is to get 3rd party app package names second part is to split package names using delimiter : third part is to replace carriage return with space

wget or curl from stdin

陌路散爱 提交于 2019-11-30 08:26:27
I'd like to download a web pages while supplying URLs from stdin. Essentially one process continuously produces URLs to stdout/file and I want to pipe them to wget or curl. (Think about it as simple web crawler if you want). This seems to work fine: tail 1.log | wget -i - -O - -q But when I use 'tail -f' and it doesn't work anymore (buffering or wget is waiting for EOF?): tail -f 1.log | wget -i - -O - -q Could anybody provide a solution using wget, curl or any other standard Unix tool? Ideally I don't won't want to restart wget in the loop, just keep it running downloading URLs as they come.

xargs、chattr命令

穿精又带淫゛_ 提交于 2019-11-30 07:43:56
一、xargs:将标准输入转化成命令行参数 用法:xargs [OPTION] ... COMMAND INITIAL-ARGS ... 使用参数INITIAL-ARGS运行COMMAND,并从输入中读取更多参数。 长选项的强制性参数对于短选项也是必需的。 非强制性参数以[方括号]表示 -0(数字),-null项之间用null而不是空格分隔。 禁用报价和反斜杠处理 -a,--arg-file = FILE从FILE而不是标准输入中读取参数 -d,--delimiter = CHARACTER输入项用CHARACTER分隔,而不是 空格处。禁用引号和反斜杠 处理 -E END如果END作为输入行出现,则其余 输入被忽略。 -e [END],--eof [= END]如果指定了END,则等效于-E END。 否则,没有文件结尾字符串 --help打印xargs选项的摘要。 -I R与--replace = R相同(必须指定R) -i,-replace = [R]用名称替换初始参数中的R 从标准输入读取。如果R是 未指定,假设{} -L,-l,--max-lines = MAX-LINES每条最多使用MAX-LINES非空白输入线 命令行 -l每行最多使用一条非空白输入行 命令行 -n,--max-args = MAX-ARGS每个命令最多使用MAX-ARGS参数 线 -P,--max

Which is faster, 'find -exec' or 'find | xargs -0'?

南楼画角 提交于 2019-11-30 04:49:45
问题 In my web application I render pages using PHP script, and then generate static HTML files from them. The static HTML are served to the users to speed up performance. The HTML files become stale eventually, and need to be deleted. I am debating between two ways to write the eviction script. The first is using a single find command, like find /var/www/cache -type f -mmin +10 -exec rm \{} \; The second form is by piping through xargs, something like find /var/www/cache -type f -mmin +10 -print0

redis数据迁移

蹲街弑〆低调 提交于 2019-11-30 03:12:50
命令: redis-cli -n 2 keys '*' | xargs -I '{}' redis-cli -n 2 migrate 目标IP 6379 '' 2 10000 COPY keys '{}' 来源: https://www.cnblogs.com/wujinhong/p/11549795.html

How can I use aliased commands with xargs?

大兔子大兔子 提交于 2019-11-29 22:59:44
I have the following alias in my .aliases: alias gi grep -i and I want to look for foo case-insensitively in all the files that have the string bar in their name: find -name \*bar\* | xargs gi foo This is what I get: xargs: gi: No such file or directory Is there any way to use aliases in xargs, or do I have to use the full version: find -name \*bar\* | xargs grep -i foo Note: This is a simple example. Besides gi I have some pretty complicated aliases that I can't expand manually so easily. Edit: I used tcsh , so please specify if an answer is shell-specific. Aliases are shell-specific - in