4

I'm very new to using UNIX/Bash. I'm currently outputting the product of a random number generator to a text file in a subdirectory using the following:

./generate > ~/workspace/pset3/find/output/output.txt

my current directory in this case would be find. Is there a way to type the path such that I can briefly specify a sub-directory of the current directory without typing the full path each time?

  • 1
    the reference to a subdirectory of the current directory would be ./subdir/filename or simply subdir/filename. Take your pick – MelBurslan Feb 12 '16 at 15:18
4

the reference to a subdirectory of the current directory would be ./subdir/filename or simply subdir/filename. in your example, if you are in ~/workspace/pset3/find and address the output.txt file, you can reference it as ./output/output.txt or output/output.txt

4

You specify the path to a desired destination from your working directory, so in your case you could just put:

> output/output.txt

Paths are always taken from your current/working directory, unless they start with '/' or '~'. In these cases, the rest of the path is relative to the root or your home directory respectively. (There may be other examples of this too)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.