LoginSignup
0
0

More than 5 years have passed since last update.

シンボリックリンクのリンク先を示す文字列を置換する

Posted at

Macのユーザー名を変えた時に旧ユーザー名を含んだシンボリックリンクがたくさんあったので、

/home/old_user/sh/foo.sh -> /home/new_user/sh/foo.sh にシンボリックリンクを変更する方法が知りたかったので聞いてみた。

ln -sfn "$(readlink existing_link | sed s/foo/bar/)" "existing_symlink"

でOK。 readlink なんてのがあったんですね。

参考

symlink - Is there way to replace value of symbolic link? - Unix & Linux Stack Exchange
http://unix.stackexchange.com/questions/92643/is-there-way-to-replace-value-of-symbolic-link/92648?noredirect=1#92648

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0