Create, update and delete files and directories#

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

!mkdir tests
create-delete.ipynb   index.rst             tests
file-system.ipynb     pipes-filters.ipynb
grep-find.ipynb       shell-variables.ipynb

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

!touch tests/test_file.txt
!ls tests

Now we change the suffix of the file:

!mv tests/test_file.txt tests/
!ls tests

Now we make a copy of this file:

!cp tests/ tests/
!ls tests

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

!cp -r tests tests.bak
!ls tests.bak

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

!rm -r tests tests.bak
create-delete.ipynb   grep-find.ipynb       pipes-filters.ipynb
file-system.ipynb     index.rst             shell-variables.ipynb

Transfering files#


--2023-07-19 17:00:21--
Auflösen des Hostnamens (… 2606:4700:3036::6815:51cd, 2606:4700:3033::ac43:a44c,, ...
Verbindungsaufbau zu (|2606:4700:3036::6815:51cd|:443 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 303 See Other
Platz: [folgend]
--2023-07-19 17:00:21--
Auflösen des Hostnamens (…
Verbindungsaufbau zu (||:443 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
Länge: 51 [binary/octet-stream]
Wird in »dvc.list« gespeichert.

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

2023-07-19 17:00:22 (1,13 MB/s) - »dvc.list« gespeichert [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 supresses the output to the screen


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

!curl -o dvc.list
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    85  100    85    0     0    251      0 --:--:-- --:--:-- --:--:--   254