{"id":17229057,"url":"https://github.com/fwartner/replace","last_synced_at":"2026-04-24T16:31:46.660Z","repository":{"id":104343896,"uuid":"177622540","full_name":"fwartner/replace","owner":"fwartner","description":"Cli utility for replacing text in files, written in golang and compiled for usage in Docker images","archived":false,"fork":false,"pushed_at":"2023-03-07T02:45:30.000Z","size":28,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-03T07:31:05.198Z","etag":null,"topics":["docker","golang","replace-text"],"latest_commit_sha":null,"homepage":"https://wartner.io","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/fwartner.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-25T16:18:51.000Z","updated_at":"2022-06-23T08:25:03.000Z","dependencies_parsed_at":"2023-07-07T09:00:53.604Z","dependency_job_id":null,"html_url":"https://github.com/fwartner/replace","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/fwartner/replace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwartner%2Freplace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwartner%2Freplace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwartner%2Freplace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwartner%2Freplace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fwartner","download_url":"https://codeload.github.com/fwartner/replace/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwartner%2Freplace/sbom","scorecard":{"id":415206,"data":{"date":"2025-08-11","repo":{"name":"github.com/fwartner/replace","commit":"e0033858fa44d790642dd51e4aedd81d0d24985d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/8 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact 1.0.0 not signed: https://api.github.com/repos/fwartner/replace/releases/16330698","Warn: release artifact 1.0.0 does not have provenance: https://api.github.com/repos/fwartner/replace/releases/16330698"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/fwartner/replace/build.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/fwartner/replace/build.yml/main?enable=pin","Warn: containerImage not pinned by hash: Dockerfile:1","Warn: containerImage not pinned by hash: Dockerfile:14: pin your Docker image by updating alpine to alpine@sha256:4bcff63911fcb4448bd4fdacec207030997caf25e9bea4045fa6c8c44de311d1","Warn: containerImage not pinned by hash: release/Dockerfile:1: pin your Docker image by updating alpine to alpine@sha256:4bcff63911fcb4448bd4fdacec207030997caf25e9bea4045fa6c8c44de311d1","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 containerImage dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Vulnerabilities","score":0,"reason":"14 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2022-0411 / GHSA-3839-6r69-m497 / GHSA-xg2h-wx96-xgxr","Warn: Project is vulnerable to: GO-2023-1992 / GHSA-x3jr-pf6g-c48f","Warn: Project is vulnerable to: GO-2022-0229 / GHSA-cjjc-xp8v-855w","Warn: Project is vulnerable to: GO-2020-0012 / GHSA-ffhg-7mh4-33c4","Warn: Project is vulnerable to: GO-2021-0227 / GHSA-3vm4-22fp-5rfm","Warn: Project is vulnerable to: GO-2022-0968 / GHSA-gwc9-m7rh-j2ww","Warn: Project is vulnerable to: GO-2021-0356 / GHSA-8c26-wmh5-6g9v","Warn: Project is vulnerable to: GO-2024-2961","Warn: Project is vulnerable to: GO-2023-2402 / GHSA-45x7-px36-x8w8","Warn: Project is vulnerable to: GO-2024-3321 / GHSA-v778-237x-gjrc","Warn: Project is vulnerable to: GO-2025-3487 / GHSA-hcg3-q754-cr77","Warn: Project is vulnerable to: GO-2021-0061 / GHSA-r88r-gmrh-7j83","Warn: Project is vulnerable to: GO-2022-0956 / GHSA-6q6q-88xp-6f2r","Warn: Project is vulnerable to: GO-2020-0036 / GHSA-wxc4-f4m6-wwqv"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T23:39:19.460Z","repository_id":104343896,"created_at":"2025-08-18T23:39:19.460Z","updated_at":"2025-08-18T23:39:19.460Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32230888,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["docker","golang","replace-text"],"created_at":"2024-10-15T04:45:52.439Z","updated_at":"2026-04-24T16:31:46.640Z","avatar_url":"https://github.com/fwartner.png","language":"Go","funding_links":["https://github.com/sponsors/fwartner)!"],"categories":[],"sub_categories":[],"readme":"# replace\nCli utility for replacing text in files, written in golang and compiled for usage in Docker images\n\nInspired by https://github.com/piranha/goreplace\n\n## Support me\n\nI invest a lot of resources into creating [best in class open source packages](https://wartner.io/open-source). You can support me by [buying one of my paid products](https://wartner.io/open-source/support-me).\n\nI highly appreciate you sending us a postcard from your hometown, mentioning which of my prpjects you are using. You'll find my address on [my contact page](https://wartner.me/contact). I publish all received postcards on [my virtual postcard wall](https://wartner.io/open-source/postcards).\n\n### Note\nThis section is inspired by my friends at [Spatie](https://github.com/spatie).\n\n## Features\n\n- Simple search\u0026replace for terms specified as normal shell argument (for escaping only normal shell quotes needed)\n- Can use regular expressions for search\u0026replace with and without backrefs (`--regex` and `--regex-backrefs`)\n- Supports multiple changesets (search\u0026replace terms)\n- Replace the whole line with replacement when line is matching (`--mode=line`)\n- ... and add the line at the bottom if there is no match (`--mode=lineinfile`)\n- Use [golang template](https://golang.org/pkg/text/template/) with [Sprig template functions]](https://masterminds.github.io/sprig/) (`--mode=template`)\n- Can store file as other filename (eg. `replace ./configuration.tmpl:./configuration.conf`)\n- Can replace files in directory (`--path`) and offers file pattern matching functions (`--path-pattern` and `--path-regex`)\n- Can read also stdin for search\u0026replace or template handling\n- Supports Linux, MacOS, Windows and ARM/ARM64 (Rasbperry Pi and others)\n\n## Usage\n\n```\nUsage:\n  go-replace\n\nApplication Options:\n      --threads=                                Set thread concurrency for replacing in multiple files at same time (default: 20)\n  -m, --mode=[replace|line|lineinfile|template] replacement mode - replace: replace match with term; line: replace line with term; lineinfile: replace line with term or\n                                                if not found append to term to file; template: parse content as golang template, search value have to start uppercase\n                                                (default: replace)\n  -s, --search=                                 search term\n  -r, --replace=                                replacement term\n      --lineinfile-before=                      add line before this regex\n      --lineinfile-after=                       add line after this regex\n  -i, --case-insensitive                        ignore case of pattern to match upper and lowercase characters\n      --stdin                                   process stdin as input\n  -o, --output=                                 write changes to this file (in one file mode)\n      --output-strip-ext=                       strip file extension from written files (also available in multi file mode)\n      --once=[keep|unique]                      replace search term only one in a file, keep duplicaes (keep, default) or remove them (unique)\n      --regex                                   treat pattern as regex\n      --regex-backrefs                          enable backreferences in replace term\n      --regex-posix                             parse regex term as POSIX regex\n      --path=                                   use files in this path\n      --path-pattern=                           file pattern (* for wildcard, only basename of file)\n      --path-regex=                             file pattern (regex, full path)\n      --ignore-empty                            ignore empty file list, otherwise this will result in an error\n  -v, --verbose                                 verbose mode\n      --dry-run                                 dry run mode\n  -V, --version                                 show version and exit\n      --dumpversion                             show only version number and exit\n  -h, --help                                    show this help message\n```\n\nFiles must be specified as arguments and will be overwritten after parsing. If you want an alternative location for\nsaving the file the argument can be specified as `source:destination`, eg.\n`go-replace -s foobar -r barfoo daemon.conf.tmpl:daemon.conf`.\n\nIf `--path` (with or without `--path-pattern` or `--path-regex`) the files inside path are used as source and will\nbe overwritten. If `daemon.conf.tmpl` should be written as `daemon.conf` the option `--output-strip-ext=.tmpl` will do\nthis based on the source file name.\n\nRegular expression's back references can be activated with `--regex-backrefs` and must be specified as `$1, $2 ... $9`.\n\n\n| Mode       | Description                                                                                                                                                    |\n|:-----------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| replace    | Replace search term inside one line with replacement.                                                                                                          |\n| line       | Replace line (if matched term is inside) with replacement.                                                                                                     |\n| lineinfile | Replace line (if matched term is inside) with replacement. If no match is found in the whole file the line will be appended to the bottom of the file.         |\n| template   | Parse content as [golang template](https://golang.org/pkg/text/template/), arguments are available via `{{.Arg.Name}}` or environment vars via `{{.Env.Name}}` |\n\n### Examples\n\n| Command                                                            | Description                                                                                      |\n|:-------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------|\n| `go-replace -s foobar -r barfoo file1 file2`                       | Replaces `foobar` to `barfoo` in file1 and file2                                                 |\n| `go-replace --regex -s 'foo.*' -r barfoo file1 file2`               | Replaces the regex `foo.*` to `barfoo` in file1 and file2                                        |\n| `go-replace --regex --ignore-case -s 'foo.*' -r barfoo file1 file2` | Replaces the regex `foo.*` (and ignore case) to `barfoo` in file1 and file2                      |\n| `go-replace --mode=line -s 'foobar' -r barfoo file1 file2`          | Replaces all lines with content `foobar` to `barfoo` (whole line) in file1 and file2             |\n| `go-replace -s 'foobar' -r barfoo --path=./ --path-pattern='*.txt'` | Replaces all lines with content `foobar` to `barfoo` (whole line) in *.txt files in current path |\n\n### Example with golang templates\n\nWithing the template there are [Template functions available from Sprig](https://masterminds.github.io/sprig/).\n\nConfiguration file `daemon.conf.tmpl`:\n```\n\u003cVirtualHost ...\u003e\n    ServerName {{env \"SERVERNAME\"}}\n    DocumentRoot {{env \"DOCUMENTROOT\"}}\n\u003cVirtualHost\u003e\n\n```\n\nProcess file with:\n\n```bash\nexport SERVERNAME=www.foobar.example\nexport DOCUMENTROOT=/var/www/foobar.example/\ngo-replace --mode=template daemon.conf.tmpl:daemon.conf\n```\n\nReuslt file `daemon.conf`:\n```\n\u003cVirtualHost ...\u003e\n    ServerName www.foobar.example\n    DocumentRoot /var/www/foobar.example/\n\u003cVirtualHost\u003e\n```\n\n## Installation\n\n```bash\nREPLACE_VERSION=1.0.0 \\\n\u0026\u0026 wget -O /usr/local/bin/replace https://github.com/fwartner/replace/releases/download/REPLACE_VERSION/gr-64-linux \\\n\u0026\u0026 chmod +x /usr/local/bin/replace\n```\n\n## Docker images\n\n| Image                          | Description                                     |\n|:-------------------------------|:------------------------------------------------|\n| `wartnerio/replace:latest`  | Latest release, binary only                     |\n| `wartnerio/replace:master`  | Current development version in branch `master`  |\n| `wartnerio/replace:develop` | Current development version in branch `develop` |\n  \n If you like what I am doing please consider [sponsor my work](https://github.com/sponsors/fwartner)!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffwartner%2Freplace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffwartner%2Freplace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffwartner%2Freplace/lists"}