0

I have this shell script from here. Right now it outputs something like this:

File Path: afp://serveraddress.com/Volumes/Sharepoint/Folder/test.txt Parent Folder: afp://serveraddress.com/Volumes/Sharepoint/Folder

If I were to paste this into a browser it fails because of the /Volumes/ portion of the output.

Is there a way to use this same output but strip the volumes from the output? My current code looks like this:

toTheClipboard="File Path: afp://serveraddress.com$(echo $1 | sed 's/ /%20/g') Parent Folder: afp://serveraddress.com$(dirname "$1" | sed 's/ /%20/g')"
pbcopy<<<"$toTheClipboard"
1

This is how I'd do it:

toTheClipboard="File Path: afp://serveraddress.com$(sed -e 's: :%20:g' -e 's:/Volumes::' <<< "$1") Parent Folder: afp://serveraddress.com$(dirname "$1" | sed -e 's: :%20:g' -e 's:/Volumes::')"
pbcopy<<<"$toTheClipboard"
  • How does that work - you should know it is better to give some context – Mark Mar 6 '18 at 2:08
  • @Mark, Normally I would however the author started this in a another question a couple of days ago which frankly was not a well written question and was further exacerbated by a botched edit by bmike, which he never fixed. The author then injected additional parameters after I answered, and has done it again via this new question. The sad thing is the author should have been more clear in his original question as to his needs. I'm not inclined under the circumstances to spend any time other then providing the code necessary to do what's asked. That said, that's what the manual pages are for! – user3439894 Mar 6 '18 at 2:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .