{"id":15674789,"url":"https://github.com/sgreben/subst","last_synced_at":"2025-05-06T23:27:06.067Z","repository":{"id":57603895,"uuid":"129748320","full_name":"sgreben/subst","owner":"sgreben","description":"substitutes $variables in text. single binary, no dependencies. linux, osx, windows.","archived":false,"fork":false,"pushed_at":"2019-02-15T09:41:56.000Z","size":66,"stargazers_count":14,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T04:02:54.901Z","etag":null,"topics":["envsubst","simpler","stdin","stdout","substitution","variables"],"latest_commit_sha":null,"homepage":"","language":"Go","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/sgreben.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2018-04-16T13:31:47.000Z","updated_at":"2023-12-09T18:55:26.000Z","dependencies_parsed_at":"2022-08-29T23:51:33.122Z","dependency_job_id":null,"html_url":"https://github.com/sgreben/subst","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgreben%2Fsubst","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgreben%2Fsubst/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgreben%2Fsubst/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgreben%2Fsubst/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sgreben","download_url":"https://codeload.github.com/sgreben/subst/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252784936,"owners_count":21803787,"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":["envsubst","simpler","stdin","stdout","substitution","variables"],"created_at":"2024-10-03T15:50:47.179Z","updated_at":"2025-05-06T23:27:06.050Z","avatar_url":"https://github.com/sgreben.png","language":"Go","readme":"# subst - substitute $variables in text\n\n`subst` parses its arguments as `KEY=VALUE` pairs, substitutes `$KEY`s by `VALUE`s in stdin, and writes the result to stdout.\n\n![screenshot](docs/shot.png)\n\n\u003c!-- TOC --\u003e\n\n- [Get it](#get-it)\n- [Use it](#use-it)\n  - [Examples](#examples)\n- [Comments](#comments)\n\n\u003c!-- /TOC --\u003e\n\n## Get it\n\nUsing go get:\n\n```bash\ngo get -u github.com/sgreben/subst\n```\n\nOr [download the binary](https://github.com/sgreben/subst/releases/latest) from the releases page.\n\n```bash\n# Linux\ncurl -LO https://github.com/sgreben/subst/releases/download/1.1.1/subst_1.1.1_linux_x86_64.zip\nunzip subst_1.1.1_linux_x86_64.zip\n\n# OS X\ncurl -LO https://github.com/sgreben/subst/releases/download/1.1.1/subst_1.1.1_osx_x86_64.zip\nunzip subst_1.1.1_osx_x86_64.zip\n\n# Windows\ncurl -LO https://github.com/sgreben/subst/releases/download/1.1.1/subst_1.1.1_windows_x86_64.zip\nunzip subst_1.1.1_windows_x86_64.zip\n```\n\n## Use it\n\n`subst` uses key=value mappings given as CLI arguments, reads from stdin, and writes to stdout. The stdin input is line-buffered.\n\n```text\n\nsubst [OPTIONS] [KEY=VAL [KEY=VAL...]]\n\nUsage of subst:\n  -q    suppress all logs\n  -escape string\n        set the escape string. if set, a '$' preceded by the escape string does not lead to expansion\n  -unknown value\n        handling of unknown keys, one of [ignore empty error] (default ignore)\n```\n\n### Examples\n\n```shell\n$ cat template.yaml\nname: $NAME\nurl: $URL\ncomment: $COMMENT\n\n$ cat template.yaml | subst -q NAME=jp  URL=github.com/sgreben/jp COMMENT=\nname: jp\nurl: github.com/sgreben/jp\ncomment:\n\n$ cat template.yaml | subst -q NAME=jp\nname: jp\nurl: $URL\ncomment: $COMMENT\n\n$ cat template.yaml | subst -q -unknown=empty NAME=jp\nname: jp\nurl:\ncomment:\n```\n\nWithout the `-q` flag, `subst` also prints to stderr:\n\n```shell\n2018/04/16 15:18:37 undefined key: $URL, using value \"$URL\"\n2018/04/16 15:18:37 undefined key: $COMMENT, using value \"$COMMENT\"\n```\n\nYou can substitute environment variables (like `envsubst`) by letting the shell substitute their values:\n\n```shell\n$ subst USER=\"$USER\" SHELL=\"$SHELL\"\n$USER\nsgreben\n$SHELL\n/bin/zsh\n```\n\nTo ignore occurrences of defined variables, you can define an escape string using the `-escape` flag:\n\n```shell\n$ echo 'unescaped: $X, ${X}. escaped: \\$X, \\${X}.' | subst -escape '\\' X=value\nunescaped: value, value. escaped: $X, ${X}.\n```\n\n## Comments\n\nFeel free to [leave a comment](https://github.com/sgreben/subst/issues/1) or create an issue.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgreben%2Fsubst","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgreben%2Fsubst","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgreben%2Fsubst/lists"}