The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 304,011     Votes:  15 
Tags: command-line   files   copy   grub  
Link: 🔍 See Original Answer on Ask Ubuntu ⧉ 🔗

URL: https://askubuntu.com/q/835659
Title: Copy file to current directory?
ID: /2016/10/11/Copy-file-to-current-directory_
Created: October 11, 2016    Edited:  October 11, 2016
Upload: April 8, 2024    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


For the destination directory use a single dot ‘.

Long Answer

From your home directory type the following:

rick@dell:~$ mkdir a && mkdir a/b && mkdir a/b/c && mkdir a/b/c2
────────────────────────────────────────────────────────────────
rick@dell:~$ cd a/b/c
────────────────────────────────────────────────────────────────
rick@dell:~/a/b/c$ cp /etc/default/grub .
────────────────────────────────────────────────────────────────
rick@dell:~/a/b/c$ cp /etc/default/grub ..
────────────────────────────────────────────────────────────────
rick@dell:~/a/b/c$ cp /etc/default/grub ../c2
────────────────────────────────────────────────────────────────
rick@dell:~/a/b/c$ cd ../../
────────────────────────────────────────────────────────────────
rick@dell:~/a$ tree
.
└── b
    ├── c
    │   └── grub
    ├── c2
    │   └── grub
    └── grub

3 directories, 3 files

We created 4 directories on one line by using && to join multiple lines together. Then changed to the directory a/b/c, which is the current directory for the following copy commands:

Next we changed directory to our grand-parent directory (a) using cd ../../.

Finally we use tree to show all the directories and files under directory a.

⇧ Command-line snake game? Huawei Technologies Co., Ltd. E353/E3131 contains software intended to be automatically started. Wifi doesn't work  ⇩