xargs

Run shell script for every file in directory

◇◆丶佛笑我妖孽 提交于 2021-02-07 07:14:57
问题 I have a bunch of files in a directory all named YYYY_MM_DD -rw-r--r-- 1 root root 480K Apr 21 13:17 2012_04_05 -rw-r--r-- 1 root root 483K Apr 21 13:17 2012_04_06 -rw-r--r-- 1 root root 484K Apr 21 13:17 2012_04_07 -rw-r--r-- 1 root root 480K Apr 21 13:17 2012_04_08 -rw-r--r-- 1 root root 344K Apr 21 13:17 2012_04_09 -rw-r--r-- 1 root root 66K Apr 21 13:17 2012_04_10 -rw-r--r-- 1 root root 461K Apr 21 13:17 2012_04_11 -rw-r--r-- 1 root root 475K Apr 21 15:09 2012_04_17 -rw-r--r-- 1 root root

Run shell script for every file in directory

ぐ巨炮叔叔 提交于 2021-02-07 07:14:05
问题 I have a bunch of files in a directory all named YYYY_MM_DD -rw-r--r-- 1 root root 480K Apr 21 13:17 2012_04_05 -rw-r--r-- 1 root root 483K Apr 21 13:17 2012_04_06 -rw-r--r-- 1 root root 484K Apr 21 13:17 2012_04_07 -rw-r--r-- 1 root root 480K Apr 21 13:17 2012_04_08 -rw-r--r-- 1 root root 344K Apr 21 13:17 2012_04_09 -rw-r--r-- 1 root root 66K Apr 21 13:17 2012_04_10 -rw-r--r-- 1 root root 461K Apr 21 13:17 2012_04_11 -rw-r--r-- 1 root root 475K Apr 21 15:09 2012_04_17 -rw-r--r-- 1 root root

what is the difference between -L and -n in xargs

久未见 提交于 2021-02-07 05:59:13
问题 Per xargs --help: -L, --max-lines=MAX-LINES use at most MAX-LINES non-blank input lines per command line -n, --max-args=MAX-ARGS use at most MAX-ARGS arguments per command line It is very confusing. Is there any difference between -L and -n? ls *.h | xargs -L 1 echo ls *.h | xargs -n 1 echo 回答1: -n splits on any whitespace, -L splits on newlines. Examples: $ echo {1..10} 1 2 3 4 5 6 7 8 9 10 $ echo {1..10} | xargs -n 1 1 2 3 4 5 6 7 8 9 10 $ echo {1..10} | xargs -L 1 1 2 3 4 5 6 7 8 9 10 $

git grep and xargs in Windows Batch file?

风格不统一 提交于 2021-02-07 04:29:18
问题 I am trying to create a Windows friendly .bat implementation of the following .sh script. The top few lines are all fine, just add SET and cd is fine. git grep is fine, however, xargs isn't... What would the git grep | xargs logic look like in .bat ? INFINITY=10000 TOPDIR=$(pwd) METEOR_DIR="./code" cd "$METEOR_DIR" # Call git grep to find all js files with the appropriate comment tags, # and only then pass it to JSDoc which will parse the JS files. # This is a whole lot faster than calling

git grep and xargs in Windows Batch file?

孤街浪徒 提交于 2021-02-07 04:28:45
问题 I am trying to create a Windows friendly .bat implementation of the following .sh script. The top few lines are all fine, just add SET and cd is fine. git grep is fine, however, xargs isn't... What would the git grep | xargs logic look like in .bat ? INFINITY=10000 TOPDIR=$(pwd) METEOR_DIR="./code" cd "$METEOR_DIR" # Call git grep to find all js files with the appropriate comment tags, # and only then pass it to JSDoc which will parse the JS files. # This is a whole lot faster than calling

How to run multiple curl requests in parallel with multiple variables

瘦欲@ 提交于 2021-02-05 08:44:38
问题 Set Up I currently have the below script working to download files with curl , using a ref file with multiple variables. When I created the script it suited my needs however as the ref file has gotten larger and the data I am requesting via curl is takes longer to generate, my script is now taking too much time to complete. Objective I want to be able to update this script so I have curl request and download multiple files as they are ready - as opposed to waiting for each file to be

How to run multiple curl requests in parallel with multiple variables

落花浮王杯 提交于 2021-02-05 08:44:26
问题 Set Up I currently have the below script working to download files with curl , using a ref file with multiple variables. When I created the script it suited my needs however as the ref file has gotten larger and the data I am requesting via curl is takes longer to generate, my script is now taking too much time to complete. Objective I want to be able to update this script so I have curl request and download multiple files as they are ready - as opposed to waiting for each file to be

Multiple read from a txt file in bash (parallel processing )

一世执手 提交于 2021-02-05 05:57:53
问题 Here is a simple bash script for HTTP status code while read url do urlstatus=$(curl -o /dev/null --silent --head --write-out '%{http_code}' "${url}" --max-time 5 ) echo "$url $urlstatus" >> urlstatus.txt done < $1 I am reading URL from text file but it processes only one at a time, taking too much time, GNU parallel and xargs also process one line at time (tested) How to process simultaneous URL for processing to improve timing? In other words threading of URL file rather than bash commands

How can I use xargs to run a function in a command substitution for each match?

妖精的绣舞 提交于 2021-01-29 08:36:16
问题 While writing Bash functions for string replacements I have encountered a strange behaviour when using xargs. This is actually driving me mad currently as I cannot get it to work. Fortunately I have been able to nail it down to the following simple example: Define a simple function which doubles every character of the given parameter: function subs { echo $1 | sed -E "s/(.)/\1\1/g"; } Call the function: echo $(subs "ABC") As expected the output is: AABBCC Now call the function using xargs: