1
adapter= /Volumes/My\ Passport/Documents/adapters.fa

Can I create this variable so that I can just refer to adapter for the exact file (and its location)?

derobert
  • 109,670
ozarka
  • 287

2 Answers2

2

It's perfectly legal to use a variable that way; when you refer to the variable, it will resolve to that file path.

This may be out of scope of your question, but the variable will only last as long as the shell it is created in, unless you add it to the environment with export or setenv, or adding it to .bashrc (or similar).

0

You can put any string you like in a variable. But you can't put spaces around the equal sign in an assignment:

adapter=/Volumes/My\ Passport/Documents/adapters.fa

or

adapter='/Volumes/My Passport/Documents/adapters.fa'

After this definition, you can use "$adapter" in the shell to refer to that file. Note the double quotes — without them the shell would split the value at the space.

open "$adapter"

This definition adapter is only useful in a shell. For example, you can't type $adapter in a file opening dialog and have it bring up that value. If you want to define a shortcut for a file that you can use everywhere, you can create a symbolic link in an easy-to-reach place.