![FreeBSD의 ln 명령에서 -F 옵션의 용도는 무엇입니까?](https://linux55.com/image/184796/FreeBSD%EC%9D%98%20ln%20%EB%AA%85%EB%A0%B9%EC%97%90%EC%84%9C%20-F%20%EC%98%B5%EC%85%98%EC%9D%98%20%EC%9A%A9%EB%8F%84%EB%8A%94%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F.png)
존재하다https://www.freebsd.org/cgi/man.cgi?ln, 그것은 말한다
-F If the target file already exists and is a directory, then remove
it so that the link may occur. The -F option should be used with
either -f or -i options. If neither -f nor -i is specified, -f is
implied. The -F option is a no-op unless -s is specified.
그렇다면 이 옵션을 어떻게 사용하나요? 파일을 디렉토리에 연결하면 해당 디렉토리에 동일한 이름의 링크가 생성됩니다.
답변1
말했듯이 대상 파일이 이미 존재하고 디렉터리인 경우 ln
링크가 발생할 수 있도록 삭제됩니다.
mkdir dir1
echo hello >file
ln -s file dir1 # Creates a broken symlink at dir1/file pointing to itself
cat dir1/file
cat: dir1/file: Too many levels of symbolic links
mkdir dir2
echo hello >file
ln -Fs file dir2 # Removes dir1 and creates a symlink of dir1 pointing to file
cat dir2/file
cat: dir2/file: Not a directory
cat dir2
hello