-
-
Save stantonk/2884411 to your computer and use it in GitHub Desktop.
Read a list of values separated by newlines from stdin and output the values on a single line separated by commas to stdout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
###### | |
# Why is this useful? | |
# | |
# Say you have a list of ids in a database tool like SequelPro in | |
# the result of a query. It is possible to copy an entire column | |
# to the clipboard. But then you may want to pass that list of | |
# ids as a comma-separated list into an HTTP(S) API endpoint for | |
# testing. This solves that problem! | |
# | |
# Example: | |
# Let's say your clipboard contains "123\n456\n\789\n" | |
# $ pbpaste | csv | pbcopy | |
# | |
# This changes your clipboard to contain: | |
# "123,456,789" | |
# | |
# Now you can plop it into a URL: | |
# | |
# http://someapi.com/some/api/endpoint/123,456,789/metadata | |
pbpaste | tr '\n' ',' | pbcopy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment