
たとえば、各日のセッションの最後に、最後に日付が添付された履歴ファイルを作成したいとします。
つまり、 history > history07162012.txt のような感じになります。
答え1
履歴ファイルが非表示になっていると仮定すると( で始まる.
)、次のようにします。
ls -1 ~/.*history
出力:
/home/birei/.bash_history
/home/birei/.mysql_history
/home/birei/.ptksh_history
/home/birei/.sqlite_history
/home/birei/.xsh2_history
/home/birei/.xsh_history
実行する:
for hist_file in ~/.*history; do cp "$hist_file" "$hist_file$(date +%m%d%Y).txt"; done
その後:
ls -1 ~/.*history*
出力は次のようになります。
/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
あなたの質問に役立つことを願っています。