ln -nsf와 같은 링크를 만드는 이유는 무엇입니까? remove existing

이것은 무엇을 하는가?

ln -nsf

나는 ln -s하드 링크가 아니라 기호 링크를 생성한다는 것을 알고 있습니다. 즉, 링크를 삭제할 수 있으며 링크가 연결된 생각을 삭제하지 않습니다. 그러나 다른 것은 무엇을 의미합니까? (-nf)

업데이트 : 알겠습니다 … 그래서 명령 줄 에서이 내용을 찾을 수 있다는 것을 기억했습니다. 다음은 입력을 통해 얻은 내용입니다 ln --help.

-f, --force                 remove existing destination files
-n, --no-dereference        treat destination that is a symlink to a
                            directory as if it were a normal file

그러나 이것의 의미가 무엇인지 여전히 명확하지 않습니다. 왜 이렇게 소프트 / 심볼 링크를 만들고 싶습니까?



답변

BSD 매뉴얼 페이지에서 :

 -f    If the target file already exists, then unlink it so that the link
           may occur.  (The -f option overrides any previous -i options.)

 -n    If the target_file or target_dir is a symbolic link, do not follow
           it.  This is most useful with the -f option, to replace a symlink
           which may point to a directory.

답변

-n옵션 (함께 -f) 힘이 ln디렉토리에 대한 심볼릭 링크를 업데이트합니다. 그게 무슨 뜻이야?

2 개의 디렉토리가 있다고 가정

기존의 심볼릭 링크

  • 바즈-> 바

이제 대신 foo 를 가리 키도록 baz 를 업데이트하려고합니다 . 네가 방금하면

ln -sf foo baz

당신은 얻을 것이다

  • baz / foo-> foo
  • baz-> bar (변경되지 않음)
  • 바 / foo-> foo

추가하면 -n

ln -sfn foo baz

당신이 원하는 것을 얻습니다.

  • 바즈-> 푸

그것은 ‘참조 해제되지 않음’의 의미입니다. 기존 링크를 확인하지 않고 새 링크를 해당 디렉토리에 배치하는 대신 업데이트하십시오.


답변

ln의 모든 옵션은 다음과 같습니다. 여기에 -n과 -f가 있습니다.

 -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
       none is specified, -f is implied.
       The -F option is a no-op unless -s option is specified.

 -h    If the target_file or target_dir is a symbolic link, do not
       follow it.  This is most useful with the -f option, to replace
       a symlink which may point to a directory.

 -f    If the target file already exists, then unlink it so that the
       link may occur.  (The -f option overrides any previous -i options.)

 -i    Cause ln to write a prompt to standard error if the target file
       exists.  If the response from the standard input begins with the
       character `y' or `Y', then unlink the target file so that the link
       may occur.  Otherwise, do not attempt the link.  (The -i option
       overrides any previous -f options.)

 -n    Same as -h, for compatibility with other ln implementations.

 -s    Create a symbolic link.

 -v    Cause ln to be verbose, showing files as they are processed.

답변

“man ln”을 입력하여 다음을 찾을 수 있습니다.

   -f, --force
          remove existing destination files

   -n, --no-dereference
          treat destination that is a symlink to a directory as if it were
          a normal file

답변

-f, –force 기존 대상 파일 제거

-n, –no-dereference는 디렉토리에 대한 심볼릭 링크 인 대상을 마치 일반 파일 인 것처럼 처리합니다.


답변

-f 는 명령의 대상이 기존 파일 인 경우 제거하고 새 링크로 교체해야한다고 말합니다. (유닉스에 영향을받는 시스템에서 “파일”에는 디렉토리, 링크, 파이프 등이 포함될 수 있습니다.)

-n 수정 -f, 사용자가 지정하는 대상이 기존의 심볼릭 링크의 경우는해야한다고 말을 하지 제거 할 수.