====== Dateien ====== Besonderheiten bei Dateinamen: * Gross / Kleinschreibung wird unterschieden (( kann man mit e2fsprogs >= 1.45.7 abschalten, habe ich auf Servern aber noch nie gesehen: https://lwn.net/Articles/784041/ )) * ''.''-Dateien(( Kommentar dazu von [[wpde>Rob Pike]] am 03.08.2012 ---- A lesson in shortcuts. Long ago, as the design of the Unix file system was being worked out, the entries . and .. appeared, to make navigation easier. I'm not sure but I believe .. went in during the Version 2 rewrite, when the file system became hierarchical (it had a very different structure early on). When one typed ls, however, these files appeared, so either Ken or Dennis added a simple test to the program. It was in assembler then, but the code in question was equivalent to something like this: if (name[0] == '.') continue; This statement was a little shorter than what it should have been, which is if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) continue; but hey, it was easy. Two things resulted. First, a bad precedent was set. A lot of other lazy programmers introduced bugs by making the same simplification. Actual files beginning with periods are often skipped when they should be counted. Second, and much worse, the idea of a "hidden" or "dot" file was created. As a consequence, more lazy programmers started dropping files into everyone's home directory. I don't have all that much stuff installed on the machine I'm using to type this, but my home directory has about a hundred dot files and I don't even know what most of them are or whether they're still needed. Every file name evaluation that goes through my home directory is slowed down by this accumulated sludge. I'm pretty sure the concept of a hidden file was an unintended consequence. It was certainly a mistake. How many bugs and wasted CPU cycles and instances of human frustration (not to mention bad design) have resulted from that one small shortcut about 40 years ago? Keep that in mind next time you want to cut a corner in your code. (For those who object that dot files serve a purpose, I don't dispute that but counter that it's the files that serve the purpose, not the convention for their names. They could just as easily be in $HOME/cfg or $HOME/lib, which is what we did in Plan 9, which had no dot files. Lessons can be learned.) ---- Quelle: https://plus.google.com/+RobPikeTheHuman/posts/R58WgWwN9jp)) * / ist Verzeichnis-Trenner ===== normale Dateien ===== * Es besteht kein Zwang zur Dateinamen-Erweiterung (wie z. B. cmd.exe bei MSDOS). (( wenn man wissen will, was für eine Datei man vor sich hat, dann kann man mit Hilfe von [[https://media.ccc.de/v/gpn14_-_5852_-_de_-_medientheater_-_201406201430_-_identifizierung_von_dateien_mit_file_libmagic_-_christoph_biedl|file]] den Inhalt analysieren.)) * Punkte sind Zeichen wie alle anderen auch in Dateinamen. Aufgabe: Ändern sich die Zeitstempel einer Datei beim Umbenennen? Was ist mit dem Verzeichnis, in dem die Datei liegt? ===== Verzeichnisse ===== Besondere Verzeichnisse: * ''..'' * ''.'' Befehle aus [[befehle#befehle_fuer_verzeichnisse|Verzeichnisse]] ausprobieren Befehle aus [[befehle#befehle_fuer_dateien|Dateien]] ausprobieren **Übung:** mkdir testdir cd testdir Welche Möglichkeiten gibt es, von hier aus ins Heimatverzeichnis zurückzukehren? **Übung:** Wo ist der Unterschied zwischen ... touch me cp -v me backup ... und ... rm -r backup mkdir backup touch me cp -v me backup ? **Übung:** mkdir /tmp/user-backup1 Kopiere alle Dateien und Unterverzeichnisse aus Deinem Heimatverzeichnis ins neu angelegte Verzeichnis ''/tmp/user-backup1''. Achtung: nicht das Heimatverzeichnis selbst! Zusatzaufgabe: mkdir /tmp/user-backup2 Verschiebe alle Dateien und Unterverzeichnisse aus dem grade erstellten Verzeichnis ''/tmp/user-backup1'' in das neue Verzeichnis ''/tmp/user-backup2'' (( Lösung1: mv /tmp/user-backup/* /tmp/user-backup2 mv /tmp/user-backup/.* /tmp/user-backup2 Lösung2: shopt -s dotglob mv /tmp/user-backup/* /tmp/user-backup2 )) ===== weitere Dateitypen ===== siehe [[admin_grundlagen:Dateitypen]]