{"id":17160275,"url":"https://github.com/obfusk/map.sh","last_synced_at":"2026-04-29T01:02:15.426Z","repository":{"id":145667167,"uuid":"13790236","full_name":"obfusk/map.sh","owner":"obfusk","description":"map.sh - map/filter for bash","archived":false,"fork":false,"pushed_at":"2013-11-18T22:02:07.000Z","size":140,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-04T11:36:54.925Z","etag":null,"topics":["bash","map","shell"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/obfusk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-23T01:07:26.000Z","updated_at":"2020-06-18T13:33:41.000Z","dependencies_parsed_at":"2023-03-23T01:16:00.816Z","dependency_job_id":null,"html_url":"https://github.com/obfusk/map.sh","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/obfusk/map.sh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obfusk%2Fmap.sh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obfusk%2Fmap.sh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obfusk%2Fmap.sh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obfusk%2Fmap.sh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/obfusk","download_url":"https://codeload.github.com/obfusk/map.sh/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obfusk%2Fmap.sh/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32405904,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"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":["bash","map","shell"],"created_at":"2024-10-14T22:24:16.769Z","updated_at":"2026-04-29T01:02:15.411Z","avatar_url":"https://github.com/obfusk.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"[]: {{{1\n\n    File        : README.md\n    Maintainer  : Felix C. Stegerman \u003cflx@obfusk.net\u003e\n    Date        : 2013-11-18\n\n    Copyright   : Copyright (C) 2013  Felix C. Stegerman\n    Version     : v0.2.0\n\n[]: }}}1\n\n## Description\n[]: {{{1\n\n  map.sh - map/filter for bash\n\n  `map` evaluates an expression for arguments, files, or lines;\n  `filter` filters arguments, files, or lines based on the exit status\n  of an expression; the expression can refer to its argument as `$it`.\n\n  Options:\n\n  * `-v` prints the expression before evaluating it; only for `map`\n  * `-t` ignores non-zero exit status; only for `map`\n  * `-l` maps/filters lines instead of arguments\n  * `-0` input lines end with 0 byte, not newline; implies `-l`\n  * `-z` output lines end with 0 byte, not newline; only for `filter`\n  * `-f` treats arguments/lines as files, providing the canonical path\n    as `$path`, the absolute path as `$abs`, the basename as `$base`,\n    the dirname as `$dir`, and the dirnames of the canonical and\n    absolute paths as `$path_dir` and `$abs_dir`\n\n#\n\n  The canonical path is the result of `Cwd::abs_path`: the absolute\n  path with all symlinks followed.\n\n[]: }}}1\n\n## Examples\n[]: {{{1\n\n[]: {{{2\n\n```bash\nmap 'echo $it' foo bar baz\n# foo\n# bar\n# baz\n\nmap -v 'echo \"$it\"; echo ${#it}' foo 'bar baz'\n# ==\u003e echo foo\n# foo\n# ==\u003e echo 3\n# 3\n# ==\u003e echo 'bar baz'\n# bar baz\n# ==\u003e echo 7\n# 7\n\nmap -f 'echo \"$path\"' foo bar/baz\n# /canonical/path/to/foo\n# /canonical/path/to/baz\n```\n\n```bash\n# find files and echo dirname of canonical path\nfind -type f -print0 | sort -z | map -f0 'echo \"$path_dir\"'\n\n# print message for existing files\nmap -t 'test -e \"$it\" \u0026\u0026 echo \"$it exists\"' foo bar baz\n\n# run git command in multiple directories, like mgit\nmap 'cd \"$it\"; pwd; git status; echo' *\n```\n\n[]: }}}2\n\n[]: {{{2\n\n```bash\nfilter '[ -e \"$it\" ]' existing-file nonexisting-file\n# existing-file\n\nfilter '[[ \"$it\" =~ foo ]]' foo bar food\n# foo\n# food\n\nfilter '[ -L \"$it\" ]' some/file some/link | map -fl 'echo \"$abs\"'\n# /absolute/path/to/some/link\n```\n\n```bash\n# find 4-char files\nfind -type f -print0 | sort -z | filter -f0 '[ \"${#base}\" == 4 ]'\n```\n\n[]: }}}2\n\n[]: }}}1\n\n## License\n[]: {{{1\n\n  GPLv2 [1].\n\n[]: }}}1\n\n## References\n[]: {{{1\n\n  [1] GNU General Public License, version 2\n  --- http://www.opensource.org/licenses/GPL-2.0\n\n[]: }}}1\n\n[]: ! ( vim: set tw=70 sw=2 sts=2 et fdm=marker : )\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobfusk%2Fmap.sh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fobfusk%2Fmap.sh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobfusk%2Fmap.sh/lists"}