6

Adding a shell script (/bin/bash) to an automator workflow (copy file path) I want to use this to strip the constant prefix '/Volumes/' from the variable path which is being copied to the clipboard.

EG The copy file path workflow copies '/Volumes/GRAID/audiovideo.mov' to the clipboard, the path I desire to paste is 'GRAID/audiovideo.mov'

zanetu
  • 3,740
  • 1
  • 21
  • 17
bzzWomp
  • 136
  • 4
  • 19

1 Answers1

8

To remove a known constant prefix /Volumes/ from a shell variable named foo, you can write:

foo="${foo#/Volumes/}"

(See the Bash Reference Manual, ยง3.5.3 "Shell Parameter Expansion".)

ruakh
  • 175,680
  • 26
  • 273
  • 307