symbolic link に touch してもファイルの更新日が変わらない・・・
シンボリックリンクに touch したんですけど、ファイルの日付が変わりません。
takuya@:~$ ll .bash_sample lrwxrwxrwx 1 takuya takuya 7 2016-06-03 15:16 .bash_sample -> .bashrc takuya@:~$ touch .bash_sample takuya@:~$ ll .bash_sample lrwxrwxrwx 1 takuya takuya 7 2016-06-03 15:16 .bash_sample -> .bashrc
変わらない。。。何でだ。
調べたら、実体を変えるとのこと
stack overflow を見たら、ここ来る前にman 見ろ!!と書いてあった。すいません。
man に書いてあった。
-h If the file is a symbolic link, change the times of the link itself rather than the file that the link points to. Note that -h implies -c and thus will not create any new files.
ファイルがシンボリックリンクの時は、ファイルのリンク先ではなく、リンクファイルその物ズバリの日付を変えたい時に使う。-h では -c でファイルを作らないようにするから注意しろ。とのこと。
touch -h とすれば symlink の日付を変更できる。
なるほどやってみよう
takuya@:~$ ll .bash_sample lrwxrwxrwx 1 takuya takuya 7 2016-06-03 15:16 .bash_sample -> .bashrc takuya@:~$ touch .bash_sample takuya@:~$ ll .bashrc .bash_sample lrwxrwxrwx 1 takuya takuya 7 2016-06-03 15:20 .bash_sample -> .bashrc
おお!変わった。
これって気づかないとはまるよなぁ。