{ "cells": [ { "cell_type": "markdown", "id": "adjustable-sphere", "metadata": {}, "source": [ "# Dateien und Verzeichnisse erstellen, aktualisieren und löschen" ] }, { "cell_type": "markdown", "id": "continental-feelings", "metadata": {}, "source": [ "Legt ein neues Verzeichnis `test` an und überprüft dieses anschließend mit `ls`:" ] }, { "cell_type": "code", "execution_count": 1, "id": "powered-lesbian", "metadata": {}, "outputs": [], "source": [ "!mkdir tests" ] }, { "cell_type": "code", "execution_count": 2, "id": "bigger-check", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "create-delete.ipynb index.rst\n", "create-delete.ipynb.license pipes-filters.ipynb\n", "file-system.ipynb pipes-filters.ipynb.license\n", "file-system.ipynb.license shell-variables.ipynb\n", "grep-find.ipynb shell-variables.ipynb.license\n", "grep-find.ipynb.license \u001b[34mtests\u001b[m\u001b[m\n" ] } ], "source": [ "!ls" ] }, { "cell_type": "markdown", "id": "baking-nebraska", "metadata": {}, "source": [ "Dann legen wir in diesem Verzeichnis die Datei `test_file.txt` an:" ] }, { "cell_type": "code", "execution_count": 3, "id": "white-render", "metadata": {}, "outputs": [], "source": [ "!touch tests/test_file.txt" ] }, { "cell_type": "code", "execution_count": 4, "id": "leading-malpractice", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "test_file.txt\n" ] } ], "source": [ "!ls tests" ] }, { "cell_type": "markdown", "id": "intelligent-richardson", "metadata": {}, "source": [ "Nun ändern wir das Suffix der Datei:" ] }, { "cell_type": "code", "execution_count": 5, "id": "mature-country", "metadata": {}, "outputs": [], "source": [ "!mv tests/test_file.txt tests/test_file.py" ] }, { "cell_type": "code", "execution_count": 6, "id": "joined-notebook", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "test_file.py\n" ] } ], "source": [ "!ls tests" ] }, { "cell_type": "markdown", "id": "conscious-peace", "metadata": {}, "source": [ "Nun erstellen wir eine Kopie dieser Datei:" ] }, { "cell_type": "code", "execution_count": 7, "id": "figured-value", "metadata": {}, "outputs": [], "source": [ "!cp tests/test_file.py tests/test_file2.py" ] }, { "cell_type": "code", "execution_count": 8, "id": "lined-moldova", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "test_file.py test_file2.py\n" ] } ], "source": [ "!ls tests" ] }, { "cell_type": "markdown", "id": "announced-patch", "metadata": {}, "source": [ "Auch ein Verzeichnis mit allen darin enthaltenen Dateien kann rekursiv mit der Option `-r` kopiert werden:" ] }, { "cell_type": "code", "execution_count": 9, "id": "persistent-funds", "metadata": {}, "outputs": [], "source": [ "!cp -r tests tests.bak" ] }, { "cell_type": "code", "execution_count": 10, "id": "subject-samuel", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "test_file.py test_file2.py\n" ] } ], "source": [ "!ls tests.bak" ] }, { "cell_type": "markdown", "id": "eight-rainbow", "metadata": {}, "source": [ "Zum Schluss löschen wir die Verzeichnisse `tests` und `tests.bak` wieder:" ] }, { "cell_type": "code", "execution_count": 11, "id": "broke-mouth", "metadata": {}, "outputs": [], "source": [ "!rm -r tests tests.bak" ] }, { "cell_type": "code", "execution_count": 12, "id": "fatty-spelling", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "create-delete.ipynb index.rst\n", "create-delete.ipynb.license pipes-filters.ipynb\n", "file-system.ipynb pipes-filters.ipynb.license\n", "file-system.ipynb.license shell-variables.ipynb\n", "grep-find.ipynb shell-variables.ipynb.license\n", "grep-find.ipynb.license\n" ] } ], "source": [ "!ls" ] }, { "cell_type": "markdown", "id": "peripheral-timer", "metadata": {}, "source": [ "## Dateien übertragen" ] }, { "cell_type": "markdown", "id": "brazilian-floating", "metadata": {}, "source": [ "### `wget`" ] }, { "cell_type": "code", "execution_count": 13, "id": "thousand-glenn", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--2024-11-05 19:34:43-- https://dvc.org/deb/dvc.list\n", "Auflösen des Hostnamens dvc.org (dvc.org)… 2606:4700:3033::ac43:a44c, 2606:4700:3036::6815:51cd, 104.21.81.205, ...\n", "Verbindungsaufbau zu dvc.org (dvc.org)|2606:4700:3033::ac43:a44c|:443 … verbunden.\n", "FEHLER: Das Zertifikat von dvc.org kann nicht geprüft werden, ausgestellt von »CN=WE1,O=Google Trust Services,C=US«:.\n", " Die Autorität des Ausstellers des Zertifikates kann lokal nicht geprüft werden.\n", "Verwenden Sie »--no-check-certificate«, um zu dem Server dvc.org eine nicht gesicherte Verbindung aufzubauen.\n" ] } ], "source": [ "!wget https://dvc.org/deb/dvc.list" ] }, { "cell_type": "markdown", "id": "subjective-bandwidth", "metadata": {}, "source": [ "* `-r` crawlt rekursiv andere Dateien und Verzeichnisse\n", "* `-np` vermeidet das Crawlen in übergeordneten Verzeichnissen\n", "* `-D` zielt nur auf den folgenden Domainnamen\n", "* `-nH` vermeidet das Anlegen eines Unterverzeichnisses für den Inhalt der Website\n", "* `-m` spiegelt mit Zeitstempel, unendlicher Rekursionstiefe und Erhaltung der FTP-Verzeichniseinstellungen\n", "* `-q` unterdrückt die Ausgabe auf dem Bildschirm" ] }, { "cell_type": "markdown", "id": "pursuant-stephen", "metadata": {}, "source": [ "### `cURL`\n", "\n", "Alternativ könnt ihr cURL verwenden, das eine viel größere Auswahl an Protokollen unterstützt." ] }, { "cell_type": "code", "execution_count": 14, "id": "royal-wilderness", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " % Total % Received % Xferd Average Speed Time Time Time Current\n", " Dload Upload Total Spent Left Speed\n", "100 85 100 85 0 0 227 0 --:--:-- --:--:-- --:--:-- 227\n" ] } ], "source": [ "!curl -o dvc.list https://dvc.org/deb/dvc.list" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.13 Kernel", "language": "python", "name": "python313" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.0" }, "latex_envs": { "LaTeX_envs_menu_present": true, "autoclose": false, "autocomplete": true, "bibliofile": "biblio.bib", "cite_by": "apalike", "current_citInitial": 1, "eqLabelWithNumbers": true, "eqNumInitial": 1, "hotkeys": { "equation": "Ctrl-E", "itemize": "Ctrl-I" }, "labels_anchors": false, "latex_user_defs": false, "report_style_numbering": false, "user_envs_cfg": false }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": {}, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 5 }