Create, update and delete files and directories

Creates a new directory test and then checks this with ls:

[1]:
!mkdir tests
[2]:
!ls
create-delete.ipynb           length.txt
create-delete.ipynb.license   pipes-filters.ipynb
file-system.ipynb             pipes-filters.ipynb.license
file-system.ipynb.license     shell-variables.ipynb
grep-find.ipynb               shell-variables.ipynb.license
grep-find.ipynb.license       sorted-length.txt
index.rst                     tests

Then we create the file test_file.txt in this directory.

[3]:
!touch tests/test_file.txt
[4]:
!ls tests
test_file.txt

Now we change the suffix of the file:

[5]:
!mv tests/test_file.txt tests/test_file.py
[6]:
!ls tests
test_file.py

Now we make a copy of this file:

[7]:
!cp tests/test_file.py tests/test_file2.py
[8]:
!ls tests
test_file.py  test_file2.py

A directory with all the files it contains is also possible recursively with the -r option:

[9]:
!cp -r tests tests.bak
[10]:
!ls tests.bak
test_file.py  test_file2.py

Finally, we delete the directories tests and tests.bak again:

[11]:
!rm -r tests tests.bak
[12]:
!ls
create-delete.ipynb           length.txt
create-delete.ipynb.license   pipes-filters.ipynb
file-system.ipynb             pipes-filters.ipynb.license
file-system.ipynb.license     shell-variables.ipynb
grep-find.ipynb               shell-variables.ipynb.license
grep-find.ipynb.license       sorted-length.txt
index.rst

Transferring files

wget

[13]:
!wget https://dvc.org/deb/dvc.list
--2026-05-20 19:56:40--  https://dvc.org/deb/dvc.list
Resolving dvc.org (dvc.org)... 199.16.172.237, 199.16.173.60
Connecting to dvc.org (dvc.org)|199.16.172.237|:443... connected.
HTTP request sent, awaiting response... 303 See Other
Location: https://downloads.dvc.org/deb/dvc.list [following]
--2026-05-20 19:56:40--  https://downloads.dvc.org/deb/dvc.list
Resolving downloads.dvc.org (downloads.dvc.org)... 2600:9000:225b:a200:1a:8fd1:7400:93a1, 2600:9000:225b:400:1a:8fd1:7400:93a1, 2600:9000:225b:9000:1a:8fd1:7400:93a1, ...
Connecting to downloads.dvc.org (downloads.dvc.org)|2600:9000:225b:a200:1a:8fd1:7400:93a1|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 51 [binary/octet-stream]
Saving to: ‘dvc.list’

dvc.list            100%[===================>]      51  --.-KB/s    in 0s

2026-05-20 19:56:40 (1,39 MB/s) - ‘dvc.list’ saved [51/51]

  • -r recursively crawls other files and directories

  • -np avoids crawling to parent directories

  • -D targets only the following domain name

  • -nH avoids creating a subdirectory for the websites content

  • -m mirrors with time stamping, time stamping, infinite recursion depth, and preservation of FTP directory settings

  • -q suppresses the output to the screen

cURL

Alternatively, you can use cURL, which supports a much larger range of protocols.

[14]:
!curl -o dvc.list https://dvc.org/deb/dvc.list
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0