Suppose my current working directory is:


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

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
| improve this answer | |

Your Answer

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