
Beispielsweise möchte ich am Ende der Sitzung für jeden Tag eine Verlaufsdatei erstellen, an deren Ende das Datum angehängt ist.
Sagen wir also „history > history07162012.txt“ oder so ähnlich.
Antwort1
Vorausgesetzt, Verlaufsdateien sind ausgeblendet (beginnend mit .
), würde ich Folgendes tun:
ls -1 ~/.*history
Mit Ausgabe:
/home/birei/.bash_history
/home/birei/.mysql_history
/home/birei/.ptksh_history
/home/birei/.sqlite_history
/home/birei/.xsh2_history
/home/birei/.xsh_history
Ausführen:
for hist_file in ~/.*history; do cp "$hist_file" "$hist_file$(date +%m%d%Y).txt"; done
Und dann:
ls -1 ~/.*history*
Mit folgender Ausgabe:
/home/birei/.bash_history
/home/birei/.bash_history07172012.txt
/home/birei/.mysql_history
/home/birei/.mysql_history07172012.txt
/home/birei/.ptksh_history
/home/birei/.ptksh_history07172012.txt
/home/birei/.sqlite_history
/home/birei/.sqlite_history07172012.txt
/home/birei/.xsh2_history
/home/birei/.xsh2_history07172012.txt
/home/birei/.xsh_history
/home/birei/.xsh_history07172012.txt
Ich hoffe, es kann Ihnen bei Ihrer Frage hilfreich sein.