Skip to content

Instantly share code, notes, and snippets.

@dfang
Created July 30, 2018 08:51
Show Gist options
  • Save dfang/f35713fde8b8f311d8050fd2bd873c5b to your computer and use it in GitHub Desktop.
Save dfang/f35713fde8b8f311d8050fd2bd873c5b to your computer and use it in GitHub Desktop.
run commands many times

puts these in .bashrc, then runx 3 date

function runx() {
  for ((n=0;n<$1;n++))
    do ${*:2}
  done
}
for i in `seq 10`; do command; done
for i in {1..10}; do command; done
seq 20 | xargs -L go run main.go
parallel go run main.go ::: {1..10}

run() {
    number=$1
    shift
    for i in `seq $number`; do
      $@
    done
}
seq 10 | xargs -I -- echo "hello"
seq 100 | parallel echo {}
seq 1 5 | xargs -I{} date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment