You can do feature creep for a long time. If you just want a basic working version (that will probably drain your battery), that can be done really quickly. This took me ~10 minutes: #!/bin/sh set -e while true; do URLS="$(xsel | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*")" && if [[ ! "${URLS}" = "${OLD_URLS}" ]]; then echo "${URLS}" >> urls.txt OLD_URLS="${URLS}" fi sleep 1 done;
eg, copying http://example.com/foo and then http://example.com/bar and then http://example.com/baz I think urls.txt would look like:
http://example.com/foo
http://example.com/foo
http://example.com/bar
http://example.com/foo
http://example.com/bar
http://example.com/baz
EDIT: I stand corrected. I should have run the code instead of mentally executing it.One issue I did find when I ran it. The shebang should be:
#!/bin/bash
as [[ is a bash built-in. I'm on Ubuntu - maybe this works on Mac as /bin/sh is an alias to /bin/bash?