My main goal is to be able use Terminal to turn
http://t.umblr.com/redirect?z=https%3A%2F%2Farchiveofourown.org%2Fworks%2F1885509&t=N2M3YmNhNjQzODU5MjI2NmE5ZjljY2Y4NWVhOTVhM2IwYzgyYzYyYixLOHhQakVRbA%3D%3D
into
https://archiveofourown.org/works/1885509
I thought a good place to start would be with finding a way to remove the http://t.umblr.com/redirect?z=
.
I triedtr -d
; however, there does not seem to be a way to remove only the first instance of a group of characters.
The following (using cut
) will only work consistently if there length of the string never changes, which means there is no guarantee for future use.
echo 'http://t.umblr.com/redirect?z=https%3A%2F%2Farchiveofourown.org%2Fworks%2F1885509&t=N2M3YmNhNjQzODU5MjI2NmE5ZjljY2Y4NWVhOTVhM2IwYzgyYzYyYixLOHhQakVRbA%3D%3D' | cut -c31-83
This looked promising:
var="http://t.umblr.com/redirect?z=https%3A%2F%2Farchiveofourown.org%2Fworks%2F1885509&t=N2M3YmNhNjQzODU5MjI2NmE5ZjljY2Y4NWVhOTVhM2IwYzgyYzYyYixLOHhQakVRbA%3D%3D" | var=${var:30}
But because I can not get | pbcopy
to work, not could I get outer to print, I have idea what it actually does.
I don't know if there is shell script that will allow me to keep what appears between the equal signs. From the tutorials and questions I have found, sed
looks like it would be my best option (if I can figure it out) but it seems to work for files, not strings.
Where is a better place for me to start?