1

Suppose my current working directory is:

    /Users/Directories

Under Directories, there are two separate directories called: firstname & last name. I move into the first name directory:

    $ cd firstname

and inside firstname, I want to create an empty file called test1.txt, so I type:

    $ touch test1.txt

This is where I am stuck: without leaving firstname, I want to create a file called test2.txt in the directory lastname. I've tried this, but it doesn't seem to work. Thanks in advance.

    $ touch test2.txt../lastname

migrated from stackoverflow.com Jan 20 '17 at 15:55

This question came from our site for professional and enthusiast programmers.

2

Simply like that :

$ touch ../lastname/test2.txt

Note that instead of touch, you can use >

$ > ../lastname/test2.txt

You can also use an absolute path

$ > /Users/Directories/lastname/test2.txt

Your Answer

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