{"id":15674280,"url":"https://github.com/k-bx/par","last_synced_at":"2025-05-06T21:48:36.500Z","repository":{"id":30054093,"uuid":"33603338","full_name":"k-bx/par","owner":"k-bx","description":"Small utility that runs multiple computations in parallel","archived":false,"fork":false,"pushed_at":"2020-04-25T20:30:07.000Z","size":39,"stargazers_count":41,"open_issues_count":4,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-19T15:34:02.576Z","etag":null,"topics":["haskell","parallel","scripting","shell"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/k-bx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-08T11:41:38.000Z","updated_at":"2023-10-13T02:25:30.000Z","dependencies_parsed_at":"2022-08-28T15:01:27.285Z","dependency_job_id":null,"html_url":"https://github.com/k-bx/par","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-bx%2Fpar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-bx%2Fpar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-bx%2Fpar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-bx%2Fpar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k-bx","download_url":"https://codeload.github.com/k-bx/par/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252776480,"owners_count":21802462,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haskell","parallel","scripting","shell"],"created_at":"2024-10-03T15:43:57.907Z","updated_at":"2025-05-06T21:48:36.453Z","avatar_url":"https://github.com/k-bx.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [![Build Status](https://travis-ci.org/k-bx/par.svg?branch=master)](https://travis-ci.org/k-bx/par) Run several commands in parallel\n\n`par` is a small utility that runs multiple commands in parallel and\nby default exits with a failure status of a first failure it sees.\n\nUse `--help` for command-line help.\n\nBasic usage example\n-------------------\n\n```\n\u003e par \"echo foo; sleep 1; echo foo; sleep 1; echo foo\" \"echo bar; sleep 1; echo bar; sleep 1; echo bar\" \u0026\u0026 echo \"success\"\nfoo\nbar\nbar\nfoo\nbar\nfoo\nsuccess\n\u003e par \"echo foo; sleep 1; foofoo\" \"echo bar; sleep 1; echo bar; sleep 1; echo bar\" \u0026\u0026 echo \"success\"\nbar\nfoo\nbar\n/bin/sh: foofoo: command not found\nbar\n```\n\nPassing commands over stdin\n---------------------------\n\nPlot 6 streams of data in real time with [feedgnuplot](https://github.com/dkogan/feedgnuplot):\n\n```\nfor n in a b c d e f; do echo PARPREFIX=$n' (while true; do echo $RANDOM; sleep 0.2; done)'; done | par | feedgnuplot --dataid --stream 0.2 --xlen 1000 --lines --points --terminal qt --exit --autolegend\n```\n\nAdding prefix to output\n-----------------------\n\n```\n\u003e par \"PARPREFIX=[fooechoer] echo foo\" \"PARPREFIX=[bar] echo bar\"\n[fooechoer] foo\n[bar] bar\n```\n\nForce success exit-code\n-----------------------\n\n```\n\u003e par --succeed \"foo\" \"bar\" \u0026\u0026 echo 'wow'\n/bin/sh: foo: command not found\n/bin/sh: bar: command not found\nwow\n```\n\nForcing processes to not buffer their output\n--------------------------------------------\n\nPrefix your subprocesses with this command:\n\n```\nstdbuf -o 0\n```\n\nInstallation\n------------\n\nFor Ubuntu 12.04, 14.04 and MacOS X download some release and put it\ninto $PATH. For others -- see \"building from source\" instructions.\n\nhttps://github.com/k-bx/par/releases\n\nExample:\n\n```\ncd /tmp\nwget https://github.com/k-bx/par/releases/download/1.0.1/par-ubuntu-12.04\nsudo mv ./par-ubuntu-12.04 /usr/local/bin/\n```\n\nBuilding from source\n--------------------\n\n1. Install [haskell stack tool](https://github.com/commercialhaskell/stack)\n2. Run `stack install`. It'll build and install tool into `~/.local/bin/par`\n\nFootnote on strings in bash/zsh\n-------------------------------\n\nMany people know that strings in bash and zsh are \"weird\", but not\nmany people know that there are good old ASCII-strings also present.\n\nDouble-quoted strings are interpolating variables and do other interesting\nthings like reacting on \"!\" sign, for example.\n\nSingle-quotes don't interpolate variables and don't react on \"!\" sign, but\nthey also don't let you quote neither single-quote nor double-quote.\n\nTurns out good old ASCII-quotes are available as $'string' syntax! Example:\n\n    \u003e echo $'foo'\n    foo\n    \u003e echo $'foo with \"doublequotes and \\'singletuoes\\' inside\"!'\n    foo with \"doublequotes and 'singletuoes' inside\"!\n\nYou are a better person with this knowledge now. $'Enjoy!'\n\nPar-like thing in pure Bash\n---------------------------\n\n```\nprefixwith() {\n    local prefix=\"$1\"\n    shift\n    stdbuf -o 0 \"$@\" 1\u003e \u003e(sed \"s/^/$prefix: /\") 2\u003e \u003e(sed \"s/^/$prefix (err): /\" \u003e\u00262)\n}\nlistenqueue() {\n    local queue=\"$1\"\n    prefixwith \"[$queue]\" kafkacat -b localhost -t $queue -o end \u0026\n}\nlistenqueue diarizer-input\nP01=$!\nlistenqueue diarizer-output\nP02=$!\nwait $P01 $P02\n```\n\nBut this has problems with stopping (need to re-create TTY).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-bx%2Fpar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk-bx%2Fpar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-bx%2Fpar/lists"}